Mercurial > emacs
comparison src/image.c @ 54920:38cb79e68369
(PNG_BG_COLOR_SHIFT): Remove.
(png_load): Fix calculation of transparent background color on X
and W32 platforms.
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Fri, 16 Apr 2004 20:08:15 +0000 |
parents | 5636e8542b77 |
children | dda0bae93c73 |
comparison
equal
deleted
inserted
replaced
54919:80ffc816e4e9 | 54920:38cb79e68369 |
---|---|
49 #define COLOR_TABLE_SUPPORT 1 | 49 #define COLOR_TABLE_SUPPORT 1 |
50 | 50 |
51 typedef struct x_bitmap_record Bitmap_Record; | 51 typedef struct x_bitmap_record Bitmap_Record; |
52 #define GET_PIXEL(ximg, x, y) XGetPixel(ximg, x, y) | 52 #define GET_PIXEL(ximg, x, y) XGetPixel(ximg, x, y) |
53 #define NO_PIXMAP None | 53 #define NO_PIXMAP None |
54 #define PNG_BG_COLOR_SHIFT 0 | |
55 | 54 |
56 #define RGB_PIXEL_COLOR unsigned long | 55 #define RGB_PIXEL_COLOR unsigned long |
57 | 56 |
58 #define PIX_MASK_RETAIN(f) 0 | 57 #define PIX_MASK_RETAIN(f) 0 |
59 #define PIX_MASK_DRAW(f) 1 | 58 #define PIX_MASK_DRAW(f) 1 |
67 #undef COLOR_TABLE_SUPPORT | 66 #undef COLOR_TABLE_SUPPORT |
68 | 67 |
69 typedef struct w32_bitmap_record Bitmap_Record; | 68 typedef struct w32_bitmap_record Bitmap_Record; |
70 #define GET_PIXEL(ximg, x, y) GetPixel(ximg, x, y) | 69 #define GET_PIXEL(ximg, x, y) GetPixel(ximg, x, y) |
71 #define NO_PIXMAP 0 | 70 #define NO_PIXMAP 0 |
72 #define PNG_BG_COLOR_SHIFT 0 | |
73 | 71 |
74 #define RGB_PIXEL_COLOR COLORREF | 72 #define RGB_PIXEL_COLOR COLORREF |
75 | 73 |
76 #define PIX_MASK_RETAIN(f) 0 | 74 #define PIX_MASK_RETAIN(f) 0 |
77 #define PIX_MASK_DRAW(f) 1 | 75 #define PIX_MASK_DRAW(f) 1 |
102 #define ZPixmap 0 /* arbitrary */ | 100 #define ZPixmap 0 /* arbitrary */ |
103 typedef struct mac_bitmap_record Bitmap_Record; | 101 typedef struct mac_bitmap_record Bitmap_Record; |
104 | 102 |
105 #define GET_PIXEL(ximg, x, y) XGetPixel(ximg, x, y) | 103 #define GET_PIXEL(ximg, x, y) XGetPixel(ximg, x, y) |
106 #define NO_PIXMAP 0 | 104 #define NO_PIXMAP 0 |
107 #define PNG_BG_COLOR_SHIFT 8 | |
108 | 105 |
109 #define RGB_PIXEL_COLOR unsigned long | 106 #define RGB_PIXEL_COLOR unsigned long |
110 | 107 |
111 #define FRAME_X_VISUAL(f) FRAME_X_DISPLAY_INFO (f)->visual | 108 #define FRAME_X_VISUAL(f) FRAME_X_DISPLAY_INFO (f)->visual |
112 #define x_defined_color mac_defined_color | 109 #define x_defined_color mac_defined_color |
1170 | 1167 |
1171 | 1168 |
1172 /* Return the `background' field of IMG. If IMG doesn't have one yet, | 1169 /* Return the `background' field of IMG. If IMG doesn't have one yet, |
1173 it is guessed heuristically. If non-zero, XIMG is an existing | 1170 it is guessed heuristically. If non-zero, XIMG is an existing |
1174 XImage object (or device context with the image selected on W32) to | 1171 XImage object (or device context with the image selected on W32) to |
1175 use for the heuristic. */ | 1172 use for the heuristic. */ |
1176 | 1173 |
1177 RGB_PIXEL_COLOR | 1174 RGB_PIXEL_COLOR |
1178 image_background (img, f, ximg) | 1175 image_background (img, f, ximg) |
1179 struct image *img; | 1176 struct image *img; |
1180 struct frame *f; | 1177 struct frame *f; |
1203 | 1200 |
1204 img->background = four_corners_best (ximg, img->width, img->height); | 1201 img->background = four_corners_best (ximg, img->width, img->height); |
1205 | 1202 |
1206 if (free_ximg) | 1203 if (free_ximg) |
1207 Destroy_Image (ximg, prev); | 1204 Destroy_Image (ximg, prev); |
1208 | 1205 |
1209 img->background_valid = 1; | 1206 img->background_valid = 1; |
1210 } | 1207 } |
1211 | 1208 |
1212 return img->background; | 1209 return img->background; |
1213 } | 1210 } |
2988 img->background = background; | 2985 img->background = background; |
2989 img->background_valid = 1; | 2986 img->background_valid = 1; |
2990 non_default_colors = 1; | 2987 non_default_colors = 1; |
2991 } | 2988 } |
2992 | 2989 |
2993 Create_Pixmap_From_Bitmap_Data (f, img, data, | 2990 Create_Pixmap_From_Bitmap_Data (f, img, data, |
2994 foreground, background, | 2991 foreground, background, |
2995 non_default_colors); | 2992 non_default_colors); |
2996 xfree (data); | 2993 xfree (data); |
2997 | 2994 |
2998 if (img->pixmap == NO_PIXMAP) | 2995 if (img->pixmap == NO_PIXMAP) |
3855 pb = (b >> (16 - dpyinfo->blue_bits)) << dpyinfo->blue_offset; | 3852 pb = (b >> (16 - dpyinfo->blue_bits)) << dpyinfo->blue_offset; |
3856 | 3853 |
3857 /* Assemble the pixel color. */ | 3854 /* Assemble the pixel color. */ |
3858 return pr | pg | pb; | 3855 return pr | pg | pb; |
3859 } | 3856 } |
3860 | 3857 |
3861 for (p = ct_table[i]; p; p = p->next) | 3858 for (p = ct_table[i]; p; p = p->next) |
3862 if (p->r == r && p->g == g && p->b == b) | 3859 if (p->r == r && p->g == g && p->b == b) |
3863 break; | 3860 break; |
3864 | 3861 |
3865 if (p == NULL) | 3862 if (p == NULL) |
4966 /* Put the image into a pixmap. */ | 4963 /* Put the image into a pixmap. */ |
4967 x_put_x_image (f, ximg, img->pixmap, width, height); | 4964 x_put_x_image (f, ximg, img->pixmap, width, height); |
4968 x_destroy_x_image (ximg); | 4965 x_destroy_x_image (ximg); |
4969 | 4966 |
4970 /* X and W32 versions did it here, MAC version above. ++kfs | 4967 /* X and W32 versions did it here, MAC version above. ++kfs |
4971 img->width = width; | 4968 img->width = width; |
4972 img->height = height; */ | 4969 img->height = height; */ |
4973 | 4970 |
4974 UNGCPRO; | 4971 UNGCPRO; |
4975 xfree (contents); | 4972 xfree (contents); |
4976 return 1; | 4973 return 1; |
5410 if (x_defined_color (f, SDATA (specified_bg), &color, 0)) | 5407 if (x_defined_color (f, SDATA (specified_bg), &color, 0)) |
5411 { | 5408 { |
5412 png_color_16 user_bg; | 5409 png_color_16 user_bg; |
5413 | 5410 |
5414 bzero (&user_bg, sizeof user_bg); | 5411 bzero (&user_bg, sizeof user_bg); |
5415 user_bg.red = color.red >> PNG_BG_COLOR_SHIFT; | 5412 user_bg.red = color.red >> 8; |
5416 user_bg.green = color.green >> PNG_BG_COLOR_SHIFT; | 5413 user_bg.green = color.green >> 8; |
5417 user_bg.blue = color.blue >> PNG_BG_COLOR_SHIFT; | 5414 user_bg.blue = color.blue >> 8; |
5418 | 5415 |
5419 fn_png_set_background (png_ptr, &user_bg, | 5416 fn_png_set_background (png_ptr, &user_bg, |
5420 PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); | 5417 PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); |
5421 } | 5418 } |
5422 } | 5419 } |
5436 | 5433 |
5437 color.pixel = FRAME_BACKGROUND_PIXEL (f); | 5434 color.pixel = FRAME_BACKGROUND_PIXEL (f); |
5438 x_query_color (f, &color); | 5435 x_query_color (f, &color); |
5439 | 5436 |
5440 bzero (&frame_background, sizeof frame_background); | 5437 bzero (&frame_background, sizeof frame_background); |
5441 frame_background.red = color.red; | 5438 frame_background.red = color.red >> 8; |
5442 frame_background.green = color.green; | 5439 frame_background.green = color.green >> 8; |
5443 frame_background.blue = color.blue; | 5440 frame_background.blue = color.blue >> 8; |
5444 #endif /* HAVE_X_WINDOWS */ | 5441 #endif /* HAVE_X_WINDOWS */ |
5445 | 5442 |
5446 #ifdef HAVE_NTGUI | 5443 #ifdef HAVE_NTGUI |
5447 COLORREF color; | 5444 COLORREF color; |
5448 png_color_16 frame_background; | 5445 png_color_16 frame_background; |
5449 color = FRAME_BACKGROUND_PIXEL (f); | 5446 color = FRAME_BACKGROUND_PIXEL (f); |
5450 #if 0 /* W32 TODO : Colormap support. */ | 5447 #if 0 /* W32 TODO : Colormap support. */ |
5451 x_query_color (f, &color); | 5448 x_query_color (f, &color); |
5452 #endif | 5449 #endif |
5453 bzero (&frame_background, sizeof frame_background); | 5450 bzero (&frame_background, sizeof frame_background); |
5454 frame_background.red = 256 * GetRValue (color); | 5451 frame_background.red = GetRValue (color); |
5455 frame_background.green = 256 * GetGValue (color); | 5452 frame_background.green = GetGValue (color); |
5456 frame_background.blue = 256 * GetBValue (color); | 5453 frame_background.blue = GetBValue (color); |
5457 #endif /* HAVE_NTGUI */ | 5454 #endif /* HAVE_NTGUI */ |
5458 | 5455 |
5459 #ifdef MAC_OS | 5456 #ifdef MAC_OS |
5460 unsigned long color; | 5457 unsigned long color; |
5461 png_color_16 frame_background; | 5458 png_color_16 frame_background; |