aboutsummaryrefslogtreecommitdiffstats
path: root/src/image.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/image.c')
-rw-r--r--src/image.c67
1 files changed, 28 insertions, 39 deletions
diff --git a/src/image.c b/src/image.c
index 8bb5ff77b22..144fe30a746 100644
--- a/src/image.c
+++ b/src/image.c
@@ -57,8 +57,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
57#endif /* HAVE_WINDOW_SYSTEM */ 57#endif /* HAVE_WINDOW_SYSTEM */
58 58
59#ifdef HAVE_X_WINDOWS 59#ifdef HAVE_X_WINDOWS
60#define COLOR_TABLE_SUPPORT 1
61
62typedef struct x_bitmap_record Bitmap_Record; 60typedef struct x_bitmap_record Bitmap_Record;
63#define GET_PIXEL(ximg, x, y) XGetPixel (ximg, x, y) 61#define GET_PIXEL(ximg, x, y) XGetPixel (ximg, x, y)
64#define NO_PIXMAP None 62#define NO_PIXMAP None
@@ -74,9 +72,6 @@ typedef struct x_bitmap_record Bitmap_Record;
74# include "w32.h" 72# include "w32.h"
75#endif 73#endif
76 74
77/* W32_TODO : Color tables on W32. */
78#undef COLOR_TABLE_SUPPORT
79
80typedef struct w32_bitmap_record Bitmap_Record; 75typedef struct w32_bitmap_record Bitmap_Record;
81#define GET_PIXEL(ximg, x, y) GetPixel (ximg, x, y) 76#define GET_PIXEL(ximg, x, y) GetPixel (ximg, x, y)
82#define NO_PIXMAP 0 77#define NO_PIXMAP 0
@@ -89,13 +84,7 @@ typedef struct w32_bitmap_record Bitmap_Record;
89 84
90#endif /* HAVE_NTGUI */ 85#endif /* HAVE_NTGUI */
91 86
92#ifdef USE_CAIRO
93#undef COLOR_TABLE_SUPPORT
94#endif
95
96#ifdef HAVE_NS 87#ifdef HAVE_NS
97#undef COLOR_TABLE_SUPPORT
98
99typedef struct ns_bitmap_record Bitmap_Record; 88typedef struct ns_bitmap_record Bitmap_Record;
100 89
101#define GET_PIXEL(ximg, x, y) XGetPixel (ximg, x, y) 90#define GET_PIXEL(ximg, x, y) XGetPixel (ximg, x, y)
@@ -109,6 +98,12 @@ typedef struct ns_bitmap_record Bitmap_Record;
109#define DefaultDepthOfScreen(screen) x_display_list->n_planes 98#define DefaultDepthOfScreen(screen) x_display_list->n_planes
110#endif /* HAVE_NS */ 99#endif /* HAVE_NS */
111 100
101#if (defined HAVE_X_WINDOWS \
102 && ! (defined HAVE_NTGUI || defined USE_CAIRO || defined HAVE_NS))
103/* W32_TODO : Color tables on W32. */
104# define COLOR_TABLE_SUPPORT 1
105#endif
106
112static void x_disable_image (struct frame *, struct image *); 107static void x_disable_image (struct frame *, struct image *);
113static void x_edge_detection (struct frame *, struct image *, Lisp_Object, 108static void x_edge_detection (struct frame *, struct image *, Lisp_Object,
114 Lisp_Object); 109 Lisp_Object);
@@ -4615,16 +4610,14 @@ colors_in_color_table (int *n)
4615static unsigned long 4610static unsigned long
4616lookup_rgb_color (struct frame *f, int r, int g, int b) 4611lookup_rgb_color (struct frame *f, int r, int g, int b)
4617{ 4612{
4618 unsigned long pixel;
4619
4620#ifdef HAVE_NTGUI 4613#ifdef HAVE_NTGUI
4621 pixel = PALETTERGB (r >> 8, g >> 8, b >> 8); 4614 return PALETTERGB (r >> 8, g >> 8, b >> 8);
4622#endif /* HAVE_NTGUI */ 4615#elif defined HAVE_NS
4623 4616 return RGB_TO_ULONG (r >> 8, g >> 8, b >> 8);
4624#ifdef HAVE_NS 4617#else
4625 pixel = RGB_TO_ULONG (r >> 8, g >> 8, b >> 8); 4618 xsignal1 (Qfile_error,
4626#endif /* HAVE_NS */ 4619 build_string ("This Emacs mishandles this image file type"));
4627 return pixel; 4620#endif
4628} 4621}
4629 4622
4630static void 4623static void
@@ -7320,7 +7313,6 @@ tiff_load (struct frame *f, struct image *img)
7320 { 7313 {
7321 unsigned char *data = (unsigned char *) xmalloc (width*height*4); 7314 unsigned char *data = (unsigned char *) xmalloc (width*height*4);
7322 uint32_t *dataptr = (uint32_t *) data; 7315 uint32_t *dataptr = (uint32_t *) data;
7323 int r, g, b, a;
7324 7316
7325 for (y = 0; y < height; ++y) 7317 for (y = 0; y < height; ++y)
7326 { 7318 {
@@ -7634,19 +7626,19 @@ gif_load (struct frame *f, struct image *img)
7634{ 7626{
7635 int rc, width, height, x, y, i, j; 7627 int rc, width, height, x, y, i, j;
7636 ColorMapObject *gif_color_map; 7628 ColorMapObject *gif_color_map;
7637 unsigned long pixel_colors[256];
7638 GifFileType *gif; 7629 GifFileType *gif;
7639 gif_memory_source memsrc; 7630 gif_memory_source memsrc;
7640 Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL); 7631 Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL);
7641 Lisp_Object specified_file = image_spec_value (img->spec, QCfile, NULL); 7632 Lisp_Object specified_file = image_spec_value (img->spec, QCfile, NULL);
7642 Lisp_Object specified_data = image_spec_value (img->spec, QCdata, NULL); 7633 Lisp_Object specified_data = image_spec_value (img->spec, QCdata, NULL);
7643 unsigned long bgcolor = 0;
7644 EMACS_INT idx; 7634 EMACS_INT idx;
7645 int gif_err; 7635 int gif_err;
7646 7636
7647#ifdef USE_CAIRO 7637#ifdef USE_CAIRO
7648 unsigned char *data = 0; 7638 unsigned char *data = 0;
7649#else 7639#else
7640 unsigned long pixel_colors[256];
7641 unsigned long bgcolor = 0;
7650 XImagePtr ximg; 7642 XImagePtr ximg;
7651#endif 7643#endif
7652 7644
@@ -7833,9 +7825,13 @@ gif_load (struct frame *f, struct image *img)
7833 gif_load call to construct and save all animation frames. */ 7825 gif_load call to construct and save all animation frames. */
7834 7826
7835 init_color_table (); 7827 init_color_table ();
7828
7829#ifndef USE_CAIRO
7836 if (STRINGP (specified_bg)) 7830 if (STRINGP (specified_bg))
7837 bgcolor = x_alloc_image_color (f, img, specified_bg, 7831 bgcolor = x_alloc_image_color (f, img, specified_bg,
7838 FRAME_BACKGROUND_PIXEL (f)); 7832 FRAME_BACKGROUND_PIXEL (f));
7833#endif
7834
7839 for (j = 0; j <= idx; ++j) 7835 for (j = 0; j <= idx; ++j)
7840 { 7836 {
7841 /* We use a local variable `raster' here because RasterBits is a 7837 /* We use a local variable `raster' here because RasterBits is a
@@ -9182,11 +9178,6 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. *
9182 int height; 9178 int height;
9183 const guint8 *pixels; 9179 const guint8 *pixels;
9184 int rowstride; 9180 int rowstride;
9185 XImagePtr ximg;
9186 Lisp_Object specified_bg;
9187 XColor background;
9188 int x;
9189 int y;
9190 9181
9191#if ! GLIB_CHECK_VERSION (2, 36, 0) 9182#if ! GLIB_CHECK_VERSION (2, 36, 0)
9192 /* g_type_init is a glib function that must be called prior to 9183 /* g_type_init is a glib function that must be called prior to
@@ -9240,16 +9231,14 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. *
9240#ifdef USE_CAIRO 9231#ifdef USE_CAIRO
9241 { 9232 {
9242 unsigned char *data = (unsigned char *) xmalloc (width*height*4); 9233 unsigned char *data = (unsigned char *) xmalloc (width*height*4);
9243 int y;
9244 uint32_t bgcolor = get_spec_bg_or_alpha_as_argb (img, f); 9234 uint32_t bgcolor = get_spec_bg_or_alpha_as_argb (img, f);
9245 9235
9246 for (y = 0; y < height; ++y) 9236 for (int y = 0; y < height; ++y)
9247 { 9237 {
9248 const guchar *iconptr = pixels + y * rowstride; 9238 const guchar *iconptr = pixels + y * rowstride;
9249 uint32_t *dataptr = (uint32_t *) (data + y * rowstride); 9239 uint32_t *dataptr = (uint32_t *) (data + y * rowstride);
9250 int x;
9251 9240
9252 for (x = 0; x < width; ++x) 9241 for (int x = 0; x < width; ++x)
9253 { 9242 {
9254 if (iconptr[3] == 0) 9243 if (iconptr[3] == 0)
9255 *dataptr = bgcolor; 9244 *dataptr = bgcolor;
@@ -9269,6 +9258,7 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. *
9269 } 9258 }
9270#else 9259#else
9271 /* Try to create a x pixmap to hold the svg pixmap. */ 9260 /* Try to create a x pixmap to hold the svg pixmap. */
9261 XImagePtr ximg;
9272 if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0)) 9262 if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0))
9273 { 9263 {
9274 g_object_unref (pixbuf); 9264 g_object_unref (pixbuf);
@@ -9279,7 +9269,8 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. *
9279 9269
9280 /* Handle alpha channel by combining the image with a background 9270 /* Handle alpha channel by combining the image with a background
9281 color. */ 9271 color. */
9282 specified_bg = image_spec_value (img->spec, QCbackground, NULL); 9272 XColor background;
9273 Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL);
9283 if (!STRINGP (specified_bg) 9274 if (!STRINGP (specified_bg)
9284 || !x_defined_color (f, SSDATA (specified_bg), &background, 0)) 9275 || !x_defined_color (f, SSDATA (specified_bg), &background, 0))
9285 x_query_frame_background_color (f, &background); 9276 x_query_frame_background_color (f, &background);
@@ -9295,9 +9286,9 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. *
9295 non-transparent images. Each pixel must be "flattened" by 9286 non-transparent images. Each pixel must be "flattened" by
9296 calculating the resulting color, given the transparency of the 9287 calculating the resulting color, given the transparency of the
9297 pixel, and the image background color. */ 9288 pixel, and the image background color. */
9298 for (y = 0; y < height; ++y) 9289 for (int y = 0; y < height; ++y)
9299 { 9290 {
9300 for (x = 0; x < width; ++x) 9291 for (int x = 0; x < width; ++x)
9301 { 9292 {
9302 int red; 9293 int red;
9303 int green; 9294 int green;
@@ -9597,8 +9588,6 @@ x_kill_gs_process (Pixmap pixmap, struct frame *f)
9597 0, 0, img->width, img->height, ~0, ZPixmap); 9588 0, 0, img->width, img->height, ~0, ZPixmap);
9598 if (ximg) 9589 if (ximg)
9599 { 9590 {
9600 int x, y;
9601
9602 /* Initialize the color table. */ 9591 /* Initialize the color table. */
9603 init_color_table (); 9592 init_color_table ();
9604 9593
@@ -9606,8 +9595,8 @@ x_kill_gs_process (Pixmap pixmap, struct frame *f)
9606 color table. After having done so, the color table will 9595 color table. After having done so, the color table will
9607 contain an entry for each color used by the image. */ 9596 contain an entry for each color used by the image. */
9608#ifdef COLOR_TABLE_SUPPORT 9597#ifdef COLOR_TABLE_SUPPORT
9609 for (y = 0; y < img->height; ++y) 9598 for (int y = 0; y < img->height; ++y)
9610 for (x = 0; x < img->width; ++x) 9599 for (int x = 0; x < img->width; ++x)
9611 { 9600 {
9612 unsigned long pixel = XGetPixel (ximg, x, y); 9601 unsigned long pixel = XGetPixel (ximg, x, y);
9613 9602