comparison src/glyphs-msw.c @ 278:90d73dddcdc4 r21-0b37

Import from CVS: tag r21-0b37
author cvs
date Mon, 13 Aug 2007 10:31:29 +0200
parents 6330739388db
children 7df0dd720c89
comparison
equal deleted inserted replaced
277:cfdf3ff11843 278:90d73dddcdc4
54 54
55 /************************************************************************/ 55 /************************************************************************/
56 /* convert from a series of RGB triples to a BITMAPINFO formated for the*/ 56 /* convert from a series of RGB triples to a BITMAPINFO formated for the*/
57 /* proper display */ 57 /* proper display */
58 /************************************************************************/ 58 /************************************************************************/
59 BITMAPINFO* EImage2DIBitmap (Lisp_Object device, int width, int height, 59 static BITMAPINFO* convert_EImage_to_DIBitmap (Lisp_Object device,
60 unsigned char *pic, 60 int width, int height,
61 int *bit_count, 61 unsigned char *pic,
62 unsigned char** bmp_data) 62 int *bit_count,
63 unsigned char** bmp_data)
63 { 64 {
64 struct device *d = XDEVICE (device); 65 struct device *d = XDEVICE (device);
65 int i,j; 66 int i,j;
66 RGBQUAD* colortbl; 67 RGBQUAD* colortbl;
67 int ncolors; 68 int ncolors;
90 bmp_info->bmiHeader.biSizeImage=width*height*3; 91 bmp_info->bmiHeader.biSizeImage=width*height*3;
91 92
92 /* bitmap data needs to be in blue, green, red triples - in that 93 /* bitmap data needs to be in blue, green, red triples - in that
93 order, eimage is in RGB format so we need to convert */ 94 order, eimage is in RGB format so we need to convert */
94 *bmp_data = xnew_array_and_zero (unsigned char, bpline * height); 95 *bmp_data = xnew_array_and_zero (unsigned char, bpline * height);
95 *bit_count = width * height * 3; 96 *bit_count = bpline * height;
96 97
97 if (!bmp_data) 98 if (!bmp_data)
98 { 99 {
99 xfree (bmp_info); 100 xfree (bmp_info);
100 return NULL; 101 return NULL;
184 185
185 /* Given a pixmap filename, look through all of the "standard" places 186 /* Given a pixmap filename, look through all of the "standard" places
186 where the file might be located. Return a full pathname if found; 187 where the file might be located. Return a full pathname if found;
187 otherwise, return Qnil. */ 188 otherwise, return Qnil. */
188 189
189 static Lisp_Object 190 Lisp_Object
190 locate_pixmap_file (Lisp_Object name) 191 mswindows_locate_pixmap_file (Lisp_Object name)
191 { 192 {
192 /* This function can GC if IN_REDISPLAY is false */ 193 /* This function can GC if IN_REDISPLAY is false */
193 Lisp_Object found; 194 Lisp_Object found;
194 195
195 /* Check non-absolute pathnames with a directory component relative to 196 /* Check non-absolute pathnames with a directory component relative to
217 } 218 }
218 219
219 return found; 220 return found;
220 } 221 }
221 222
223 #if 0
222 /* If INSTANTIATOR refers to inline data, return Qnil. 224 /* If INSTANTIATOR refers to inline data, return Qnil.
223 If INSTANTIATOR refers to data in a file, return the full filename 225 If INSTANTIATOR refers to data in a file, return the full filename
224 if it exists; otherwise, return a cons of (filename). 226 if it exists; otherwise, return a cons of (filename).
225 227
226 FILE_KEYWORD and DATA_KEYWORD are symbols specifying the 228 FILE_KEYWORD and DATA_KEYWORD are symbols specifying the
296 Lisp_Object result = alist_to_tagged_vector (image_type_tag, alist); 298 Lisp_Object result = alist_to_tagged_vector (image_type_tag, alist);
297 free_alist (alist); 299 free_alist (alist);
298 RETURN_UNGCPRO (result); 300 RETURN_UNGCPRO (result);
299 } 301 }
300 } 302 }
303 #endif
301 304
302 305
303 /* Initialize an image instance from a bitmap 306 /* Initialize an image instance from a bitmap
304 307
305 DEST_MASK specifies the mask of allowed image types. 308 DEST_MASK specifies the mask of allowed image types.
353 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = bitmap; 356 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = bitmap;
354 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = bitmap; 357 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = bitmap;
355 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = bmp_info->bmiHeader.biWidth; 358 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = bmp_info->bmiHeader.biWidth;
356 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = bmp_info->bmiHeader.biHeight; 359 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = bmp_info->bmiHeader.biHeight;
357 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = bmp_info->bmiHeader.biBitCount; 360 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = bmp_info->bmiHeader.biBitCount;
361 }
362
363 static void
364 mswindows_init_image_instance_from_eimage (struct Lisp_Image_Instance *ii,
365 int width, int height,
366 unsigned char *eimage,
367 int dest_mask,
368 Lisp_Object instantiator,
369 Lisp_Object domain)
370 {
371 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
372 BITMAPINFO* bmp_info;
373 unsigned char* bmp_data;
374 int bmp_bits;
375 COLORREF bkcolor;
376
377 if (!DEVICE_MSWINDOWS_P (XDEVICE (device)))
378 signal_simple_error ("Not an mswindows device", device);
379
380 /* this is a hack but MaskBlt and TransparentBlt are not supported
381 on most windows variants */
382 bkcolor = COLOR_INSTANCE_MSWINDOWS_COLOR
383 (XCOLOR_INSTANCE (FACE_BACKGROUND (Vdefault_face, domain)));
384
385 /* build a bitmap from the eimage */
386 if (!(bmp_info=convert_EImage_to_DIBitmap (device, width, height, eimage,
387 &bmp_bits, &bmp_data)))
388 {
389 signal_simple_error ("EImage to DIBitmap conversion failed",
390 instantiator);
391 }
392
393 /* Now create the pixmap and set up the image instance */
394 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask,
395 bmp_data, bmp_bits, instantiator);
396
397 xfree (bmp_info);
398 xfree (bmp_data);
358 } 399 }
359 400
360 void 401 void
361 mswindows_create_icon_from_image(Lisp_Object image, struct frame* f, int size) 402 mswindows_create_icon_from_image(Lisp_Object image, struct frame* f, int size)
362 { 403 {
618 signal_simple_error ("XPM to EImage conversion failed", 659 signal_simple_error ("XPM to EImage conversion failed",
619 image_instance); 660 image_instance);
620 } 661 }
621 662
622 /* build a bitmap from the eimage */ 663 /* build a bitmap from the eimage */
623 if (!(bmp_info=EImage2DIBitmap (device, width, height, eimage, 664 if (!(bmp_info=convert_EImage_to_DIBitmap (device, width, height, eimage,
624 &bmp_bits, &bmp_data))) 665 &bmp_bits, &bmp_data)))
625 { 666 {
626 signal_simple_error ("XPM to EImage conversion failed", 667 signal_simple_error ("XPM to EImage conversion failed",
627 image_instance); 668 image_instance);
628 } 669 }
629 xfree (eimage); 670 xfree (eimage);
825 866
826 CONSOLE_HAS_METHOD (mswindows, print_image_instance); 867 CONSOLE_HAS_METHOD (mswindows, print_image_instance);
827 CONSOLE_HAS_METHOD (mswindows, finalize_image_instance); 868 CONSOLE_HAS_METHOD (mswindows, finalize_image_instance);
828 CONSOLE_HAS_METHOD (mswindows, image_instance_equal); 869 CONSOLE_HAS_METHOD (mswindows, image_instance_equal);
829 CONSOLE_HAS_METHOD (mswindows, image_instance_hash); 870 CONSOLE_HAS_METHOD (mswindows, image_instance_hash);
871 CONSOLE_HAS_METHOD (mswindows, init_image_instance_from_eimage);
872 CONSOLE_HAS_METHOD (mswindows, locate_pixmap_file);
830 } 873 }
831 874
832 void 875 void
833 image_instantiator_format_create_glyphs_mswindows (void) 876 image_instantiator_format_create_glyphs_mswindows (void)
834 { 877 {