comparison src/glyphs-msw.c @ 2367:ecf1ebac70d8

[xemacs-hg @ 2004-11-04 23:05:23 by ben] commit mega-patch configure.in: Turn off -Winline and -Wchar-subscripts. Use the right set of cflags when compiling modules. Rewrite ldap configuration to separate the inclusion of lber (needed in recent Cygwin) from the basic checks for the needed libraries. add a function for MAKE_JUNK_C; initially code was added to generate xemacs.def using this, but it will need to be rewritten. add an rm -f for junk.c to avoid weird Cygwin bug with cp -f onto an existing file. Sort list of auto-detected functions and eliminate unused checks for stpcpy, setlocale and getwd. Add autodetection of Cygwin scanf problems BETA: Rewrite section on configure to indicate what flags are important and what not. digest-doc.c, make-dump-id.c, profile.c, sorted-doc.c: Add proper decls for main(). make-msgfile.c: Document that this is old junk. Move proposal to text.c. make-msgfile.lex: Move proposal to text.c. make-mswin-unicode.pl: Convert error-generating code so that the entire message will be seen as a single unrecognized token. mule/mule-ccl.el: Update docs. lispref/mule.texi: Update CCL docs. ldap/eldap.c: Mule-ize. Use EXTERNAL_LIST_LOOP_2 instead of deleted EXTERNAL_LIST_LOOP. * XEmacs 21.5.18 "chestnut" is released. --------------------------------------------------------------- MULE-RELATED WORK: --------------------------------------------------------------- --------------------------- byte-char conversion --------------------------- buffer.c, buffer.h, insdel.c, text.c: Port FSF algorithm for byte-char conversion, replacing broken previous version. Track the char position of the gap. Add functions to do char-byte conversion downwards as well as upwards. Move comments about algorithm workings to internals manual. --------------------------- work on types --------------------------- alloc.c, console-x-impl.h, dump-data.c, dump-data.h, dumper.c, dialog-msw.c, dired-msw.c, doc.c, editfns.c, esd.c, event-gtk.h, event-msw.c, events.c, file-coding.c, file-coding.h, fns.c, glyphs-eimage.c, glyphs-gtk.c, glyphs-msw.c, glyphs-shared.c, glyphs-x.c, glyphs.c, glyphs.h, gui.c, hpplay.c, imgproc.c, intl-win32.c, lrecord.h, lstream.c, keymap.c, lisp.h, libsst.c, linuxplay.c, miscplay.c, miscplay.h, mule-coding.c, nas.c, nt.c, ntheap.c, ntplay.c, objects-msw.c, objects-tty.c, objects-x.c, print.c, process-nt.c, process.c, redisplay.h, select-common.h, select-gtk.c, select-x.c, sgiplay.c, sound.c, sound.h, sunplay.c, sysfile.h, sysdep.c, syswindows.h, text.c, unexnt.c, win32.c, xgccache.c: Further work on types. This creates a full set of types for all the basic semantics of `char' that I have so far identified, so that its semantics can always be identified for the purposes of proper Mule-safe code, and the raw use of `char' always avoided. (1) More type renaming, for consistency of naming. Char_ASCII -> Ascbyte UChar_ASCII -> UAscbyte Char_Binary -> CBinbyte UChar_Binary -> Binbyte SChar_Binary -> SBinbyte (2) Introduce Rawbyte, CRawbyte, Boolbyte, Chbyte, UChbyte, and Bitbyte and use them. (3) New types Itext, Wexttext and Textcount for separating out the concepts of bytes and textual units (different under UTF-16 and UTF-32, which are potential internal encodings). (4) qxestr*_c -> qxestr*_ascii. lisp.h: New; goes with other qxe() functions. #### Maybe goes in a different section. lisp.h: Group generic int-type defs together with EMACS_INT defs. lisp.h: * lisp.h (WEXTTEXT_IS_WIDE) New defns. lisp.h: New type to replace places where int occurs as a boolean. It's signed because occasionally people may want to use -1 as an error value, and because unsigned ints are viral -- see comments in the internals manual against using them. dynarr.c: int -> Bytecount. --------------------------- Mule-izing --------------------------- device-x.c: Partially Mule-ize. dumper.c, dumper.h: Mule-ize. Use Rawbyte. Use stderr_out not printf. Use wext_*(). sysdep.c, syswindows.h, text.c: New Wexttext API for manipulation of external text that may be Unicode (e.g. startup code under Windows). emacs.c: Mule-ize. Properly deal with argv in external encoding. Use wext_*() and Wexttext. Use Rawbyte. #if 0 some old junk on SCO that is unlikely to be correct. Rewrite allocation code in run-temacs. emacs.c, symsinit.h, win32.c: Rename win32 init function and call it even earlier, to initialize mswindows_9x_p even earlier, for use in startup code (XEUNICODE_P). process.c: Use _wenviron not environ under Windows, to get Unicode environment variables. event-Xt.c: Mule-ize drag-n-drop related stuff. dragdrop.c, dragdrop.h, frame-x.c: Mule-ize. text.h: Add some more stand-in defines for particular kinds of conversion; use in Mule-ization work in frame-x.c etc. --------------------------- Freshening --------------------------- intl-auto-encap-win32.c, intl-auto-encap-win32.h: Regenerate. --------------------------- Unicode-work --------------------------- intl-win32.c, syswindows.h: Factor out common options to MultiByteToWideChar and WideCharToMultiByte. Add convert_unicode_to_multibyte_malloc() and convert_unicode_to_multibyte_dynarr() and use. Add stuff for alloca() conversion of multibyte/unicode. alloc.c: Use dfc_external_data_len() in case of unicode coding system. alloc.c, mule-charset.c: Don't zero out and reinit charset Unicode tables. This fucks up dump-time loading. Anyway, either we load them at dump time or run time, never both. unicode.c: Dump the blank tables as well. --------------------------------------------------------------- DOCUMENTATION, MOSTLY MULE-RELATED: --------------------------------------------------------------- EmacsFrame.c, emodules.c, event-Xt.c, fileio.c, input-method-xlib.c, mule-wnnfns.c, redisplay-gtk.c, redisplay-tty.c, redisplay-x.c, regex.c, sysdep.c: Add comment about Mule work needed. text.h: Add more documentation describing why DFC routines were not written to return their value. Add some other DFC documentation. console-msw.c, console-msw.h: Add pointer to docs in win32.c. emacs.c: Add comments on sources of doc info. text.c, charset.h, unicode.c, intl-win32.c, intl-encap-win32.c, text.h, file-coding.c, mule-coding.c: Collect background comments and related to text matters and internationalization, and proposals for work to be done, in text.c or Internals manual, stuff related to specific textual API's in text.h, and stuff related to internal implementation of Unicode conversion in unicode.c. Put lots of pointers to the comments to make them easier to find. s/mingw32.h, s/win32-common.h, s/win32-native.h, s/windowsnt.h, win32.c: Add bunches of new documentation on the different kinds of builds and environments under Windows and how they work. Collect this info in win32.c. Add pointers to these docs in the relevant s/* files. emacs.c: Document places with long comments. Remove comment about exiting, move to internals manual, put in pointer. event-stream.c: Move docs about event queues and focus to internals manual, put in pointer. events.h: Move docs about event stream callbacks to internals manual, put in pointer. profile.c, redisplay.c, signal.c: Move documentation to the Internals manual. process-nt.c: Add pointer to comment in win32-native.el. lisp.h: Add comments about some comment conventions. lisp.h: Add comment about the second argument. device-msw.c, redisplay-msw.c: @@#### comments are out-of-date. --------------------------------------------------------------- PDUMP WORK (MOTIVATED BY UNICODE CHANGES) --------------------------------------------------------------- alloc.c, buffer.c, bytecode.c, console-impl.h, console.c, device.c, dumper.c, lrecord.h, elhash.c, emodules.h, events.c, extents.c, frame.c, glyphs.c, glyphs.h, mule-charset.c, mule-coding.c, objects.c, profile.c, rangetab.c, redisplay.c, specifier.c, specifier.h, window.c, lstream.c, file-coding.h, file-coding.c: PDUMP: Properly implement dump_add_root_block(), which never worked before, and is necessary for dumping Unicode tables. Pdump name changes for accuracy: XD_STRUCT_PTR -> XD_BLOCK_PTR. XD_STRUCT_ARRAY -> XD_BLOCK_ARRAY. XD_C_STRING -> XD_ASCII_STRING. *_structure_* -> *_block_*. lrecord.h: some comments added about dump_add_root_block() vs dump_add_root_block_ptr(). extents.c: remove incorrect comment about pdump problems with gap array. --------------------------------------------------------------- ALLOCATION --------------------------------------------------------------- abbrev.c, alloc.c, bytecode.c, casefiddle.c, device-msw.c, device-x.c, dired-msw.c, doc.c, doprnt.c, dragdrop.c, editfns.c, emodules.c, file-coding.c, fileio.c, filelock.c, fns.c, glyphs-eimage.c, glyphs-gtk.c, glyphs-msw.c, glyphs-x.c, gui-msw.c, gui-x.c, imgproc.c, intl-win32.c, lread.c, menubar-gtk.c, menubar.c, nt.c, objects-msw.c, objects-x.c, print.c, process-nt.c, process-unix.c, process.c, realpath.c, redisplay.c, search.c, select-common.c, symbols.c, sysdep.c, syswindows.h, text.c, text.h, ui-byhand.c: New macros {alloca,xnew}_{itext,{i,ext,raw,bin,asc}bytes} for more convenient allocation of these commonly requested items. Modify functions to use alloca_ibytes, alloca_array, alloca_extbytes, xnew_ibytes, etc. also XREALLOC_ARRAY, xnew. alloc.c: Rewrite the allocation functions to factor out repeated code. Add assertions for freeing dumped data. lisp.h: Moved down and consolidated with other allocation stuff. lisp.h, dynarr.c: New functions for allocation that's very efficient when mostly in LIFO order. lisp.h, text.c, text.h: Factor out some stuff for general use by alloca()-conversion funs. text.h, lisp.h: Fill out convenience routines for allocating various kinds of bytes and put them in lisp.h. Use them in place of xmalloc(), ALLOCA(). text.h: Fill out the convenience functions so the _MALLOC() kinds match the alloca() kinds. --------------------------------------------------------------- ERROR-CHECKING --------------------------------------------------------------- text.h: Create ASSERT_ASCTEXT_ASCII() and ASSERT_ASCTEXT_ASCII_LEN() from similar Eistring checkers and change the Eistring checkers to use them instead. --------------------------------------------------------------- MACROS IN LISP.H --------------------------------------------------------------- lisp.h: Redo GCPRO declarations. Create a "base" set of functions that can be used to generate any kind of gcpro sets -- regular, ngcpro, nngcpro, private ones used in GC_EXTERNAL_LIST_LOOP_2. buffer.c, callint.c, chartab.c, console-msw.c, device-x.c, dialog-msw.c, dired.c, extents.c, ui-gtk.c, rangetab.c, nt.c, mule-coding.c, minibuf.c, menubar-msw.c, menubar.c, menubar-gtk.c, lread.c, lisp.h, gutter.c, glyphs.c, glyphs-widget.c, fns.c, fileio.c, file-coding.c, specifier.c: Eliminate EXTERNAL_LIST_LOOP, which does not check for circularities. Use EXTERNAL_LIST_LOOP_2 instead or EXTERNAL_LIST_LOOP_3 or EXTERNAL_PROPERTY_LIST_LOOP_3 or GC_EXTERNAL_LIST_LOOP_2 (new macro). Removed/redid comments on EXTERNAL_LIST_LOOP. --------------------------------------------------------------- SPACING FIXES --------------------------------------------------------------- callint.c, hftctl.c, number-gmp.c, process-unix.c: Spacing fixes. --------------------------------------------------------------- FIX FOR GEOMETRY PROBLEM IN FIRST FRAME --------------------------------------------------------------- unicode.c: Add workaround for newlib bug in sscanf() [should be fixed by release 1.5.12 of Cygwin]. toolbar.c: bug fix for problem of initial frame being 77 chars wide on Windows. will be overridden by my other ws. --------------------------------------------------------------- FIX FOR LEAKING PROCESS HANDLES: --------------------------------------------------------------- process-nt.c: Fixes for leaking handles. Inspired by work done by Adrian Aichner <adrian@xemacs.org>. --------------------------------------------------------------- FIX FOR CYGWIN BUG (Unicode-related): --------------------------------------------------------------- unicode.c: Add workaround for newlib bug in sscanf() [should be fixed by release 1.5.12 of Cygwin]. --------------------------------------------------------------- WARNING FIXES: --------------------------------------------------------------- console-stream.c: `reinit' is unused. compiler.h, event-msw.c, frame-msw.c, intl-encap-win32.c, text.h: Add stuff to deal with ANSI-aliasing warnings I got. regex.c: Gather includes together to avoid warning. --------------------------------------------------------------- CHANGES TO INITIALIZATION ROUTINES: --------------------------------------------------------------- buffer.c, emacs.c, console.c, debug.c, device-x.c, device.c, dragdrop.c, emodules.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, event-tty.c, events.c, extents.c, faces.c, file-coding.c, fileio.c, font-lock.c, frame-msw.c, glyphs-widget.c, glyphs.c, gui-x.c, insdel.c, lread.c, lstream.c, menubar-gtk.c, menubar-x.c, minibuf.c, mule-wnnfns.c, objects-msw.c, objects.c, print.c, scrollbar-x.c, search.c, select-x.c, text.c, undo.c, unicode.c, window.c, symsinit.h: Call reinit_*() functions directly from emacs.c, for clarity. Factor out some redundant init code. Move disallowed stuff that had crept into vars_of_glyphs() into complex_vars_of_glyphs(). Call init_eval_semi_early() from eval.c not in the middle of vars_of_() in emacs.c since there should be no order dependency in the latter calls. --------------------------------------------------------------- ARMAGEDDON: --------------------------------------------------------------- alloc.c, emacs.c, lisp.h, print.c: Rename inhibit_non_essential_printing_operations to inhibit_non_essential_conversion_operations. text.c: Assert on !inhibit_non_essential_conversion_operations. console-msw.c, print.c: Don't do conversion in SetConsoleTitle or FindWindow to avoid problems during armageddon. Put #errors for NON_ASCII_INTERNAL_FORMAT in places where problems would arise. --------------------------------------------------------------- CHANGES TO THE BUILD PROCEDURE: --------------------------------------------------------------- config.h.in, s/cxux.h, s/usg5-4-2.h, m/powerpc.h: Add comment about correct ordering of this file. Rearrange everything to follow this -- put all #undefs together and before the s&m files. Add undefs for HAVE_ALLOCA, C_ALLOCA, BROKEN_ALLOCA_IN_FUNCTION_CALLS, STACK_DIRECTION. Remove unused HAVE_STPCPY, HAVE_GETWD, HAVE_SETLOCALE. m/gec63.h: Deleted; totally broken, not used at all, not in FSF. m/7300.h, m/acorn.h, m/alliant-2800.h, m/alliant.h, m/altos.h, m/amdahl.h, m/apollo.h, m/att3b.h, m/aviion.h, m/celerity.h, m/clipper.h, m/cnvrgnt.h, m/convex.h, m/cydra5.h, m/delta.h, m/delta88k.h, m/dpx2.h, m/elxsi.h, m/ews4800r.h, m/gould.h, m/hp300bsd.h, m/hp800.h, m/hp9000s300.h, m/i860.h, m/ibmps2-aix.h, m/ibmrs6000.h, m/ibmrt-aix.h, m/ibmrt.h, m/intel386.h, m/iris4d.h, m/iris5d.h, m/iris6d.h, m/irist.h, m/isi-ov.h, m/luna88k.h, m/m68k.h, m/masscomp.h, m/mg1.h, m/mips-nec.h, m/mips-siemens.h, m/mips.h, m/news.h, m/nh3000.h, m/nh4000.h, m/ns32000.h, m/orion105.h, m/pfa50.h, m/plexus.h, m/pmax.h, m/powerpc.h, m/pyrmips.h, m/sequent-ptx.h, m/sequent.h, m/sgi-challenge.h, m/symmetry.h, m/tad68k.h, m/tahoe.h, m/targon31.h, m/tekxd88.h, m/template.h, m/tower32.h, m/tower32v3.h, m/ustation.h, m/vax.h, m/wicat.h, m/xps100.h: Delete C_ALLOCA, HAVE_ALLOCA, STACK_DIRECTION, BROKEN_ALLOCA_IN_FUNCTION_CALLS. All of this is auto-detected. When in doubt, I followed recent FSF sources, which also have these things deleted.
author ben
date Thu, 04 Nov 2004 23:08:28 +0000
parents ba4677f54a05
children ab71ad6ff3dd
comparison
equal deleted inserted replaced
2366:2a392e0c390a 2367:ecf1ebac70d8
1 /* mswindows-specific glyph objects. 1 /* mswindows-specific glyph objects.
2 Copyright (C) 1998, 1999, 2000 Andy Piper. 2 Copyright (C) 1998, 1999, 2000 Andy Piper.
3 Copyright (C) 2001, 2002, 2003 Ben Wing. 3 Copyright (C) 2001, 2002, 2003, 2004 Ben Wing.
4 4
5 This file is part of XEmacs. 5 This file is part of XEmacs.
6 6
7 XEmacs is free software; you can redistribute it and/or modify it 7 XEmacs is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the 8 under the terms of the GNU General Public License as published by the
160 /* convert from a series of RGB triples to a BITMAPINFO formated for the*/ 160 /* convert from a series of RGB triples to a BITMAPINFO formated for the*/
161 /* proper display */ 161 /* proper display */
162 /************************************************************************/ 162 /************************************************************************/
163 static BITMAPINFO *convert_EImage_to_DIBitmap (Lisp_Object device, 163 static BITMAPINFO *convert_EImage_to_DIBitmap (Lisp_Object device,
164 int width, int height, 164 int width, int height,
165 UChar_Binary *pic, 165 Binbyte *pic,
166 int *bit_count, 166 int *bit_count,
167 UChar_Binary **bmp_data) 167 Binbyte **bmp_data)
168 { 168 {
169 struct device *d = XDEVICE (device); 169 struct device *d = XDEVICE (device);
170 int i, j; 170 int i, j;
171 RGBQUAD *colortbl; 171 RGBQUAD *colortbl;
172 int ncolors; 172 int ncolors;
173 BITMAPINFO *bmp_info; 173 BITMAPINFO *bmp_info;
174 UChar_Binary *ip, *dp; 174 Binbyte *ip, *dp;
175 175
176 if (GetDeviceCaps (get_device_compdc (d), BITSPIXEL) > 0) 176 if (GetDeviceCaps (get_device_compdc (d), BITSPIXEL) > 0)
177 { 177 {
178 int bpline = BPLINE(width * 3); 178 int bpline = BPLINE(width * 3);
179 /* FIXME: we can do this because 24bpp implies no color table, once 179 /* FIXME: we can do this because 24bpp implies no color table, once
195 for now */ 195 for now */
196 bmp_info->bmiHeader.biSizeImage = width * height * 3; 196 bmp_info->bmiHeader.biSizeImage = width * height * 3;
197 197
198 /* bitmap data needs to be in blue, green, red triples - in that 198 /* bitmap data needs to be in blue, green, red triples - in that
199 order, eimage is in RGB format so we need to convert */ 199 order, eimage is in RGB format so we need to convert */
200 *bmp_data = xnew_array_and_zero (UChar_Binary, bpline * height); 200 *bmp_data = xnew_array_and_zero (Binbyte, bpline * height);
201 *bit_count = bpline * height; 201 *bit_count = bpline * height;
202 202
203 if (!bmp_data) 203 if (!bmp_data)
204 { 204 {
205 xfree (bmp_info, BITMAPINFO *); 205 xfree (bmp_info, BITMAPINFO *);
235 { 235 {
236 xfree (qtable, quant_table *); 236 xfree (qtable, quant_table *);
237 return NULL; 237 return NULL;
238 } 238 }
239 239
240 colortbl = (RGBQUAD *) (((UChar_Binary *) bmp_info) + 240 colortbl = (RGBQUAD *) (((Binbyte *) bmp_info) +
241 sizeof (BITMAPINFOHEADER)); 241 sizeof (BITMAPINFOHEADER));
242 242
243 bmp_info->bmiHeader.biBitCount = 8; 243 bmp_info->bmiHeader.biBitCount = 8;
244 bmp_info->bmiHeader.biCompression = BI_RGB; 244 bmp_info->bmiHeader.biCompression = BI_RGB;
245 bmp_info->bmiHeader.biSizeImage = bpline * height; 245 bmp_info->bmiHeader.biSizeImage = bpline * height;
246 bmp_info->bmiHeader.biClrUsed = ncolors; 246 bmp_info->bmiHeader.biClrUsed = ncolors;
247 bmp_info->bmiHeader.biClrImportant = ncolors; 247 bmp_info->bmiHeader.biClrImportant = ncolors;
248 248
249 *bmp_data = (UChar_Binary *) xmalloc_and_zero (bpline * height); 249 *bmp_data = xnew_array_and_zero (Binbyte, bpline * height);
250 *bit_count = bpline * height; 250 *bit_count = bpline * height;
251 251
252 if (!*bmp_data) 252 if (!*bmp_data)
253 { 253 {
254 xfree (qtable, quant_table *); 254 xfree (qtable, quant_table *);
431 431
432 static void 432 static void
433 mswindows_init_image_instance_from_eimage (Lisp_Image_Instance *ii, 433 mswindows_init_image_instance_from_eimage (Lisp_Image_Instance *ii,
434 int width, int height, 434 int width, int height,
435 int slices, 435 int slices,
436 UChar_Binary *eimage, 436 Binbyte *eimage,
437 int dest_mask, 437 int dest_mask,
438 Lisp_Object instantiator, 438 Lisp_Object instantiator,
439 Lisp_Object domain) 439 Lisp_Object domain)
440 { 440 {
441 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); 441 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
442 BITMAPINFO * bmp_info; 442 BITMAPINFO * bmp_info;
443 UChar_Binary * bmp_data; 443 Binbyte * bmp_data;
444 int bmp_bits; 444 int bmp_bits;
445 COLORREF bkcolor; 445 COLORREF bkcolor;
446 int slice; 446 int slice;
447 447
448 CHECK_MSGDI_DEVICE (device); 448 CHECK_MSGDI_DEVICE (device);
471 else 471 else
472 image_instance_add_dibitmap (ii, bmp_info, bmp_data, bmp_bits, slice, 472 image_instance_add_dibitmap (ii, bmp_info, bmp_data, bmp_bits, slice,
473 instantiator); 473 instantiator);
474 474
475 xfree (bmp_info, BITMAPINFO *); 475 xfree (bmp_info, BITMAPINFO *);
476 xfree (bmp_data, UChar_Binary *); 476 xfree (bmp_data, Binbyte *);
477 } 477 }
478 } 478 }
479 479
480 inline static void 480 inline static void
481 set_mono_pixel (UChar_Binary *bits, 481 set_mono_pixel (Binbyte *bits,
482 int bpline, int height, 482 int bpline, int height,
483 int x, int y, int white) 483 int x, int y, int white)
484 { 484 {
485 int i; 485 int i;
486 UChar_Binary bitnum; 486 Binbyte bitnum;
487 /* Find the byte on which this scanline begins */ 487 /* Find the byte on which this scanline begins */
488 i = (height - y - 1) * bpline; 488 i = (height - y - 1) * bpline;
489 /* Find the byte containing this pixel */ 489 /* Find the byte containing this pixel */
490 i += (x >> 3); 490 i += (x >> 3);
491 /* Which bit is it? */ 491 /* Which bit is it? */
492 bitnum = (UChar_Binary) (7 - (x & 7)); 492 bitnum = (Binbyte) (7 - (x & 7));
493 if (white) /* Turn it on */ 493 if (white) /* Turn it on */
494 bits[i] |= (1 << bitnum); 494 bits[i] |= (1 << bitnum);
495 else /* Turn it off */ 495 else /* Turn it off */
496 bits[i] &= ~(1 << bitnum); 496 bits[i] &= ~(1 << bitnum);
497 } 497 }
500 mswindows_initialize_image_instance_mask (Lisp_Image_Instance *image, 500 mswindows_initialize_image_instance_mask (Lisp_Image_Instance *image,
501 HDC hcdc) 501 HDC hcdc)
502 { 502 {
503 HBITMAP mask; 503 HBITMAP mask;
504 HGDIOBJ old = NULL; 504 HGDIOBJ old = NULL;
505 UChar_Binary *dibits, *and_bits; 505 Binbyte *dibits, *and_bits;
506 BITMAPINFO *bmp_info = 506 BITMAPINFO *bmp_info =
507 (BITMAPINFO *) xmalloc_and_zero (sizeof (BITMAPINFO) + sizeof (RGBQUAD)); 507 (BITMAPINFO *) xmalloc_and_zero (sizeof (BITMAPINFO) + sizeof (RGBQUAD));
508 int i, j; 508 int i, j;
509 int height = IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (image); 509 int height = IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (image);
510 510
533 bmp_info->bmiColors[0].rgbReserved = 0; 533 bmp_info->bmiColors[0].rgbReserved = 0;
534 534
535 if (!(mask = CreateDIBSection (hcdc, 535 if (!(mask = CreateDIBSection (hcdc,
536 bmp_info, 536 bmp_info,
537 DIB_RGB_COLORS, 537 DIB_RGB_COLORS,
538 (void **)&and_bits, 538 /* The intermediate cast fools gcc into
539 not outputting strict-aliasing
540 complaints */
541 (void **) (void *) &and_bits,
539 0,0))) 542 0,0)))
540 { 543 {
541 xfree (bmp_info, BITMAPINFO *); 544 xfree (bmp_info, BITMAPINFO *);
542 return; 545 return;
543 } 546 }
554 bmp_info->bmiHeader.biCompression = BI_RGB; 557 bmp_info->bmiHeader.biCompression = BI_RGB;
555 bmp_info->bmiHeader.biClrUsed = 0; 558 bmp_info->bmiHeader.biClrUsed = 0;
556 bmp_info->bmiHeader.biClrImportant = 0; 559 bmp_info->bmiHeader.biClrImportant = 0;
557 bmp_info->bmiHeader.biSizeImage = height * bpline; 560 bmp_info->bmiHeader.biSizeImage = height * bpline;
558 561
559 dibits = (UChar_Binary *) xmalloc_and_zero (bpline * height); 562 dibits = xnew_array_and_zero (Binbyte, bpline * height);
560 if (GetDIBits (hcdc, 563 if (GetDIBits (hcdc,
561 IMAGE_INSTANCE_MSWINDOWS_BITMAP (image), 564 IMAGE_INSTANCE_MSWINDOWS_BITMAP (image),
562 0, 565 0,
563 height, 566 height,
564 dibits, 567 dibits,
573 black in the original */ 576 black in the original */
574 for (i = 0; i < IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (image); i++) 577 for (i = 0; i < IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (image); i++)
575 { 578 {
576 for (j = 0; j < height; j++) 579 for (j = 0; j < height; j++)
577 { 580 {
578 UChar_Binary *idx = &dibits[j * bpline + i * 3]; 581 Binbyte *idx = &dibits[j * bpline + i * 3];
579 582
580 if (RGB (idx[2], idx[1], idx[0]) == transparent_color) 583 if (RGB (idx[2], idx[1], idx[0]) == transparent_color)
581 { 584 {
582 idx[0] = idx[1] = idx[2] = 0; 585 idx[0] = idx[1] = idx[2] = 0;
583 set_mono_pixel (and_bits, maskbpline, height, i, j, TRUE); 586 set_mono_pixel (and_bits, maskbpline, height, i, j, TRUE);
596 dibits, 599 dibits,
597 bmp_info, 600 bmp_info,
598 DIB_RGB_COLORS); 601 DIB_RGB_COLORS);
599 602
600 xfree (bmp_info, BITMAPINFO *); 603 xfree (bmp_info, BITMAPINFO *);
601 xfree (dibits, UChar_Binary *); 604 xfree (dibits, Binbyte *);
602 605
603 SelectObject(hcdc, old); 606 SelectObject(hcdc, old);
604 607
605 IMAGE_INSTANCE_MSWINDOWS_MASK (image) = mask; 608 IMAGE_INSTANCE_MSWINDOWS_MASK (image) = mask;
606 } 609 }
786 } 789 }
787 return colortbl; 790 return colortbl;
788 } 791 }
789 792
790 static int xpm_to_eimage (Lisp_Object image, const Extbyte *buffer, 793 static int xpm_to_eimage (Lisp_Object image, const Extbyte *buffer,
791 UChar_Binary **data, 794 Binbyte **data,
792 int *width, int *height, 795 int *width, int *height,
793 int *x_hot, int *y_hot, 796 int *x_hot, int *y_hot,
794 int *transp, 797 int *transp,
795 struct color_symbol *color_symbols, 798 struct color_symbol *color_symbols,
796 int nsymbols) 799 int nsymbols)
797 { 800 {
798 XpmImage xpmimage; 801 XpmImage xpmimage;
799 XpmInfo xpminfo; 802 XpmInfo xpminfo;
800 int result, i, j, transp_idx, maskbpline; 803 int result, i, j, transp_idx, maskbpline;
801 UChar_Binary *dptr; 804 Binbyte *dptr;
802 unsigned int *sptr; 805 unsigned int *sptr;
803 COLORREF color; /* the american spelling virus hits again .. */ 806 COLORREF color; /* the american spelling virus hits again .. */
804 COLORREF *colortbl; 807 COLORREF *colortbl;
805 808
806 xzero (xpmimage); 809 xzero (xpmimage);
834 837
835 *width = xpmimage.width; 838 *width = xpmimage.width;
836 *height = xpmimage.height; 839 *height = xpmimage.height;
837 maskbpline = BPLINE ((~7UL & (unsigned long)(*width + 7)) / 8); 840 maskbpline = BPLINE ((~7UL & (unsigned long)(*width + 7)) / 8);
838 841
839 *data = xnew_array_and_zero (UChar_Binary, *width * *height * 3); 842 *data = xnew_array_and_zero (Binbyte, *width * *height * 3);
840 843
841 if (!*data) 844 if (!*data)
842 { 845 {
843 XpmFreeXpmImage (&xpmimage); 846 XpmFreeXpmImage (&xpmimage);
844 XpmFreeXpmInfo (&xpminfo); 847 XpmFreeXpmInfo (&xpminfo);
847 850
848 /* build a color table to speed things up */ 851 /* build a color table to speed things up */
849 colortbl = xnew_array_and_zero (COLORREF, xpmimage.ncolors); 852 colortbl = xnew_array_and_zero (COLORREF, xpmimage.ncolors);
850 if (!colortbl) 853 if (!colortbl)
851 { 854 {
852 xfree (*data, UChar_Binary *); 855 xfree (*data, Binbyte *);
853 XpmFreeXpmImage (&xpmimage); 856 XpmFreeXpmImage (&xpmimage);
854 XpmFreeXpmInfo (&xpminfo); 857 XpmFreeXpmInfo (&xpminfo);
855 return 0; 858 return 0;
856 } 859 }
857 860
872 } 875 }
873 else if (color_symbols) 876 else if (color_symbols)
874 { 877 {
875 for (j = 0; j < nsymbols; j++) 878 for (j = 0; j < nsymbols; j++)
876 { 879 {
877 if (!qxestrcmp_c (color_symbols[j].name, 880 if (!qxestrcmp_ascii (color_symbols[j].name,
878 xpmimage.colorTable[i].symbolic)) 881 xpmimage.colorTable[i].symbolic))
879 { 882 {
880 colortbl[i] = color_symbols[j].color; 883 colortbl[i] = color_symbols[j].color;
881 goto label_found_color; 884 goto label_found_color;
882 } 885 }
903 xpmimage.colorTable[i].c_color); 906 xpmimage.colorTable[i].c_color);
904 goto label_found_color; 907 goto label_found_color;
905 } 908 }
906 909
907 label_no_color: 910 label_no_color:
908 xfree (*data, UChar_Binary *); 911 xfree (*data, Binbyte *);
909 xfree (colortbl, COLORREF *); 912 xfree (colortbl, COLORREF *);
910 XpmFreeXpmImage (&xpmimage); 913 XpmFreeXpmImage (&xpmimage);
911 XpmFreeXpmInfo (&xpminfo); 914 XpmFreeXpmInfo (&xpminfo);
912 return 0; 915 return 0;
913 916
945 { 948 {
946 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 949 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
947 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); 950 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
948 const Extbyte *bytes; 951 const Extbyte *bytes;
949 Bytecount len; 952 Bytecount len;
950 UChar_Binary *eimage; 953 Binbyte *eimage;
951 int width, height, x_hot, y_hot; 954 int width, height, x_hot, y_hot;
952 BITMAPINFO* bmp_info; 955 BITMAPINFO* bmp_info;
953 UChar_Binary* bmp_data; 956 Binbyte* bmp_data;
954 int bmp_bits; 957 int bmp_bits;
955 int nsymbols = 0, transp; 958 int nsymbols = 0, transp;
956 struct color_symbol* color_symbols = NULL; 959 struct color_symbol* color_symbols = NULL;
957 960
958 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); 961 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
993 &bmp_bits, &bmp_data))) 996 &bmp_bits, &bmp_data)))
994 { 997 {
995 signal_image_error ("XPM to EImage conversion failed", 998 signal_image_error ("XPM to EImage conversion failed",
996 image_instance); 999 image_instance);
997 } 1000 }
998 xfree (eimage, UChar_Binary *); 1001 xfree (eimage, Binbyte *);
999 1002
1000 /* Now create the pixmap and set up the image instance */ 1003 /* Now create the pixmap and set up the image instance */
1001 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask, 1004 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask,
1002 bmp_data, bmp_bits, 1, instantiator, 1005 bmp_data, bmp_bits, 1, instantiator,
1003 x_hot, y_hot, transp); 1006 x_hot, y_hot, transp);
1004 1007
1005 xfree (bmp_info, BITMAPINFO *); 1008 xfree (bmp_info, BITMAPINFO *);
1006 xfree (bmp_data, UChar_Binary *); 1009 xfree (bmp_data, Binbyte *);
1007 } 1010 }
1008 #endif /* HAVE_XPM */ 1011 #endif /* HAVE_XPM */
1009 1012
1010 /********************************************************************** 1013 /**********************************************************************
1011 * BMP * 1014 * BMP *
1333 black. It must be converted to the following format: Widths are 1336 black. It must be converted to the following format: Widths are
1334 padded to a multiple of 16. Scan lines are stored in increasing 1337 padded to a multiple of 16. Scan lines are stored in increasing
1335 byte order from left to right, big-endian within a byte. 0 = 1338 byte order from left to right, big-endian within a byte. 0 =
1336 black, 1 = white. */ 1339 black, 1 = white. */
1337 static HBITMAP 1340 static HBITMAP
1338 xbm_create_bitmap_from_data (HDC hdc, const UChar_Binary *data, 1341 xbm_create_bitmap_from_data (HDC hdc, const Binbyte *data,
1339 int width, int height, 1342 int width, int height,
1340 int mask, COLORREF fg, COLORREF bg) 1343 int mask, COLORREF fg, COLORREF bg)
1341 { 1344 {
1342 int old_width = (width + 7)/8; 1345 int old_width = (width + 7)/8;
1343 int new_width = BPLINE (2 * ((width + 15)/16)); 1346 int new_width = BPLINE (2 * ((width + 15)/16));
1344 const UChar_Binary *offset; 1347 const Binbyte *offset;
1345 void *bmp_buf = 0; 1348 void *bmp_buf = 0;
1346 UChar_Binary *new_data, *new_offset; 1349 Binbyte *new_data, *new_offset;
1347 int i, j; 1350 int i, j;
1348 BITMAPINFO *bmp_info = 1351 BITMAPINFO *bmp_info =
1349 (BITMAPINFO *) xmalloc_and_zero (sizeof(BITMAPINFO) + sizeof(RGBQUAD)); 1352 (BITMAPINFO *) xmalloc_and_zero (sizeof(BITMAPINFO) + sizeof(RGBQUAD));
1350 HBITMAP bitmap; 1353 HBITMAP bitmap;
1351 1354
1352 if (!bmp_info) 1355 if (!bmp_info)
1353 return NULL; 1356 return NULL;
1354 1357
1355 new_data = (UChar_Binary *) xmalloc_and_zero (height * new_width); 1358 new_data = xnew_array_and_zero (Binbyte, height * new_width);
1356 1359
1357 if (!new_data) 1360 if (!new_data)
1358 { 1361 {
1359 xfree (bmp_info, BITMAPINFO *); 1362 xfree (bmp_info, BITMAPINFO *);
1360 return NULL; 1363 return NULL;
1366 new_offset = new_data + i * new_width; 1369 new_offset = new_data + i * new_width;
1367 1370
1368 for (j = 0; j < old_width; j++) 1371 for (j = 0; j < old_width; j++)
1369 { 1372 {
1370 int bite = offset[j]; 1373 int bite = offset[j];
1371 new_offset[j] = ~ (UChar_Binary) 1374 new_offset[j] = ~ (Binbyte)
1372 ((flip_table[bite & 0xf] << 4) + flip_table[bite >> 4]); 1375 ((flip_table[bite & 0xf] << 4) + flip_table[bite >> 4]);
1373 } 1376 }
1374 } 1377 }
1375 1378
1376 /* if we want a mask invert the bits */ 1379 /* if we want a mask invert the bits */
1409 1412
1410 xfree (bmp_info, BITMAPINFO *); 1413 xfree (bmp_info, BITMAPINFO *);
1411 1414
1412 if (!bitmap || !bmp_buf) 1415 if (!bitmap || !bmp_buf)
1413 { 1416 {
1414 xfree (new_data, UChar_Binary *); 1417 xfree (new_data, Binbyte *);
1415 return NULL; 1418 return NULL;
1416 } 1419 }
1417 1420
1418 /* copy in the actual bitmap */ 1421 /* copy in the actual bitmap */
1419 memcpy (bmp_buf, new_data, height * new_width); 1422 memcpy (bmp_buf, new_data, height * new_width);
1420 xfree (new_data, UChar_Binary *); 1423 xfree (new_data, Binbyte *);
1421 1424
1422 return bitmap; 1425 return bitmap;
1423 } 1426 }
1424 1427
1425 /* Given inline data for a mono pixmap, initialize the given 1428 /* Given inline data for a mono pixmap, initialize the given
1426 image instance accordingly. */ 1429 image instance accordingly. */
1427 1430
1428 static void 1431 static void
1429 init_image_instance_from_xbm_inline (Lisp_Image_Instance *ii, 1432 init_image_instance_from_xbm_inline (Lisp_Image_Instance *ii,
1430 int width, int height, 1433 int width, int height,
1431 const UChar_Binary *bits, 1434 const Binbyte *bits,
1432 Lisp_Object instantiator, 1435 Lisp_Object instantiator,
1433 Lisp_Object pointer_fg, 1436 Lisp_Object pointer_fg,
1434 Lisp_Object pointer_bg, 1437 Lisp_Object pointer_bg,
1435 int dest_mask, 1438 int dest_mask,
1436 HBITMAP mask, 1439 HBITMAP mask,
1554 1557
1555 static void 1558 static void
1556 xbm_instantiate_1 (Lisp_Object image_instance, Lisp_Object instantiator, 1559 xbm_instantiate_1 (Lisp_Object image_instance, Lisp_Object instantiator,
1557 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 1560 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
1558 int dest_mask, int width, int height, 1561 int dest_mask, int width, int height,
1559 const UChar_Binary *bits) 1562 const Binbyte *bits)
1560 { 1563 {
1561 Lisp_Object mask_data = find_keyword_in_vector (instantiator, Q_mask_data); 1564 Lisp_Object mask_data = find_keyword_in_vector (instantiator, Q_mask_data);
1562 Lisp_Object mask_file = find_keyword_in_vector (instantiator, Q_mask_file); 1565 Lisp_Object mask_file = find_keyword_in_vector (instantiator, Q_mask_file);
1563 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 1566 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
1564 HDC hdc = get_device_compdc (XDEVICE (IMAGE_INSTANCE_DEVICE (ii))); 1567 HDC hdc = get_device_compdc (XDEVICE (IMAGE_INSTANCE_DEVICE (ii)));
1565 HBITMAP mask = 0; 1568 HBITMAP mask = 0;
1566 1569
1567 if (!NILP (mask_data)) 1570 if (!NILP (mask_data))
1568 { 1571 {
1569 UChar_Binary *ext_data; 1572 Binbyte *ext_data;
1570 1573
1571 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (XCDR (XCDR (mask_data))), 1574 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (XCDR (XCDR (mask_data))),
1572 C_STRING_ALLOCA, ext_data, 1575 C_STRING_ALLOCA, ext_data,
1573 Qbinary); 1576 Qbinary);
1574 mask = xbm_create_bitmap_from_data (hdc, 1577 mask = xbm_create_bitmap_from_data (hdc,
1592 Lisp_Object instantiator, 1595 Lisp_Object instantiator,
1593 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 1596 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
1594 int dest_mask, Lisp_Object UNUSED (domain)) 1597 int dest_mask, Lisp_Object UNUSED (domain))
1595 { 1598 {
1596 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); 1599 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
1597 const UChar_Binary *ext_data; 1600 const Binbyte *ext_data;
1598 1601
1599 assert (!NILP (data)); 1602 assert (!NILP (data));
1600 1603
1601 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (XCDR (XCDR (data))), 1604 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (XCDR (XCDR (data))),
1602 C_STRING_ALLOCA, ext_data, 1605 C_STRING_ALLOCA, ext_data,
1634 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 1637 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
1635 int dest_mask, Lisp_Object UNUSED (domain)) 1638 int dest_mask, Lisp_Object UNUSED (domain))
1636 { 1639 {
1637 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); 1640 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
1638 int i, stattis; 1641 int i, stattis;
1639 UChar_Binary *p, *bits, *bp; 1642 Binbyte *p, *bits, *bp;
1640 const CIbyte * volatile emsg = 0; 1643 const CIbyte * volatile emsg = 0;
1641 const UChar_Binary * volatile dstring; 1644 const Binbyte * volatile dstring;
1642 1645
1643 assert (!NILP (data)); 1646 assert (!NILP (data));
1644 1647
1645 TO_EXTERNAL_FORMAT (LISP_STRING, data, 1648 TO_EXTERNAL_FORMAT (LISP_STRING, data,
1646 C_STRING_ALLOCA, dstring, 1649 C_STRING_ALLOCA, dstring,
1647 Qbinary); 1650 Qbinary);
1648 1651
1649 if ((p = (UChar_Binary *) strchr ((char *) dstring, ':'))) 1652 if ((p = (Binbyte *) strchr ((char *) dstring, ':')))
1650 { 1653 {
1651 dstring = p + 1; 1654 dstring = p + 1;
1652 } 1655 }
1653 1656
1654 /* Must use setjmp not SETJMP because we used jmp_buf above not JMP_BUF */ 1657 /* Must use setjmp not SETJMP because we used jmp_buf above not JMP_BUF */
1672 } 1675 }
1673 1676
1674 if (emsg) 1677 if (emsg)
1675 signal_image_error_2 (emsg, data, Qimage); 1678 signal_image_error_2 (emsg, data, Qimage);
1676 1679
1677 bp = bits = (UChar_Binary *) ALLOCA (PIXELS / 8); 1680 bp = bits = alloca_binbytes (PIXELS / 8);
1678 1681
1679 /* the compface library exports char F[], which uses a single byte per 1682 /* the compface library exports char F[], which uses a single byte per
1680 pixel to represent a 48x48 bitmap. Yuck. */ 1683 pixel to represent a 48x48 bitmap. Yuck. */
1681 for (i = 0, p = (UChar_Binary *) F; i < (PIXELS / 8); ++i) 1684 for (i = 0, p = (Binbyte *) F; i < (PIXELS / 8); ++i)
1682 { 1685 {
1683 int n, b; 1686 int n, b;
1684 /* reverse the bit order of each byte... */ 1687 /* reverse the bit order of each byte... */
1685 for (b = n = 0; b < 8; ++b) 1688 for (b = n = 0; b < 8; ++b)
1686 { 1689 {
1687 n |= ((*p++) << b); 1690 n |= ((*p++) << b);
1688 } 1691 }
1689 *bp++ = (UChar_Binary) n; 1692 *bp++ = (Binbyte) n;
1690 } 1693 }
1691 1694
1692 xbm_instantiate_1 (image_instance, instantiator, pointer_fg, 1695 xbm_instantiate_1 (image_instance, instantiator, pointer_fg,
1693 pointer_bg, dest_mask, 48, 48, bits); 1696 pointer_bg, dest_mask, 48, 48, bits);
1694 } 1697 }
2819 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); 2822 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
2820 /* get the text from a control */ 2823 /* get the text from a control */
2821 if (EQ (prop, Q_text)) 2824 if (EQ (prop, Q_text))
2822 { 2825 {
2823 Charcount tchar_len = qxeSendMessage (wnd, WM_GETTEXTLENGTH, 0, 0); 2826 Charcount tchar_len = qxeSendMessage (wnd, WM_GETTEXTLENGTH, 0, 0);
2824 Extbyte *buf = (Extbyte *) ALLOCA (XETCHAR_SIZE * (tchar_len + 1)); 2827 Extbyte *buf = alloca_extbytes (XETCHAR_SIZE * (tchar_len + 1));
2825 2828
2826 qxeSendMessage (wnd, WM_GETTEXT, (WPARAM)tchar_len + 1, (LPARAM) buf); 2829 qxeSendMessage (wnd, WM_GETTEXT, (WPARAM)tchar_len + 1, (LPARAM) buf);
2827 return build_tstr_string (buf); 2830 return build_tstr_string (buf);
2828 } 2831 }
2829 return Qunbound; 2832 return Qunbound;
2856 if (EQ (prop, Q_text)) 2859 if (EQ (prop, Q_text))
2857 { 2860 {
2858 long item = qxeSendMessage (wnd, CB_GETCURSEL, 0, 0); 2861 long item = qxeSendMessage (wnd, CB_GETCURSEL, 0, 0);
2859 Charcount tchar_len = qxeSendMessage (wnd, CB_GETLBTEXTLEN, 2862 Charcount tchar_len = qxeSendMessage (wnd, CB_GETLBTEXTLEN,
2860 (WPARAM)item, 0); 2863 (WPARAM)item, 0);
2861 Extbyte *buf = (Extbyte *) ALLOCA (XETCHAR_SIZE * (tchar_len + 1)); 2864 Extbyte *buf = alloca_extbytes (XETCHAR_SIZE * (tchar_len + 1));
2862 qxeSendMessage (wnd, CB_GETLBTEXT, (WPARAM)item, (LPARAM) buf); 2865 qxeSendMessage (wnd, CB_GETLBTEXT, (WPARAM)item, (LPARAM) buf);
2863 return build_tstr_string (buf); 2866 return build_tstr_string (buf);
2864 } 2867 }
2865 return Qunbound; 2868 return Qunbound;
2866 } 2869 }