aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Rumney2009-01-03 11:16:32 +0000
committerJason Rumney2009-01-03 11:16:32 +0000
commit8b7d0a16b2a5074f23516b8ca0e16c76ae85d93b (patch)
tree8e71f743a10ad960afbaa97a24d524c27613695d /src
parent958a2b4c49b5f39a1eee119f311bb0995f7d29e1 (diff)
downloademacs-8b7d0a16b2a5074f23516b8ca0e16c76ae85d93b.tar.gz
emacs-8b7d0a16b2a5074f23516b8ca0e16c76ae85d93b.zip
* w32term.c (x_query_colors, x_query_color): New functions.
* image.c (x_to_xcolors, png_load): Eliminate W32 specific code. (svg_load_image): Cast returned pointers from dynamically loaded functions. Eliminate W32 specific code.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog8
-rw-r--r--src/image.c54
-rw-r--r--src/w32term.c29
3 files changed, 48 insertions, 43 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index c1d5eff96ab..54731699d0a 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
12009-01-03 Jason Rumney <jasonr@gnu.org>
2
3 * w32term.c (x_query_colors, x_query_color): New functions.
4
5 * image.c (x_to_xcolors, png_load): Eliminate W32 specific code.
6 (svg_load_image): Cast returned pointers from dynamically loaded
7 functions. Eliminate W32 specific code.
8
12009-01-02 Dan Nicolaescu <dann@ics.uci.edu> 92009-01-02 Dan Nicolaescu <dann@ics.uci.edu>
2 10
3 * nsfns.m (x_set_foreground_color, x_set_background_color) 11 * nsfns.m (x_set_foreground_color, x_set_background_color)
diff --git a/src/image.c b/src/image.c
index 827e35d7b7a..9d19d0130cb 100644
--- a/src/image.c
+++ b/src/image.c
@@ -79,6 +79,11 @@ typedef struct w32_bitmap_record Bitmap_Record;
79#define FRAME_X_VISUAL(f) FRAME_X_DISPLAY_INFO (f)->visual 79#define FRAME_X_VISUAL(f) FRAME_X_DISPLAY_INFO (f)->visual
80#define x_defined_color w32_defined_color 80#define x_defined_color w32_defined_color
81#define DefaultDepthOfScreen(screen) (one_w32_display_info.n_cbits) 81#define DefaultDepthOfScreen(screen) (one_w32_display_info.n_cbits)
82
83/* Functions from w32term.c that depend on XColor (so can't go in w32term.h
84 without modifying lots of files). */
85extern void x_query_colors (struct frame *f, XColor *colors, int ncolors);
86extern void x_query_color (struct frame *f, XColor *color);
82#endif /* HAVE_NTGUI */ 87#endif /* HAVE_NTGUI */
83 88
84#ifdef HAVE_NS 89#ifdef HAVE_NS
@@ -4783,9 +4788,9 @@ x_to_xcolors (f, img, rgb_p)
4783 { 4788 {
4784 XColor *row = p; 4789 XColor *row = p;
4785 4790
4786#ifdef HAVE_X_WINDOWS 4791#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI)
4787 for (x = 0; x < img->width; ++x, ++p) 4792 for (x = 0; x < img->width; ++x, ++p)
4788 p->pixel = XGetPixel (ximg, x, y); 4793 p->pixel = GET_PIXEL (ximg, x, y);
4789 if (rgb_p) 4794 if (rgb_p)
4790 x_query_colors (f, row, img->width); 4795 x_query_colors (f, row, img->width);
4791 4796
@@ -4797,16 +4802,9 @@ x_to_xcolors (f, img, rgb_p)
4797 p->pixel = GET_PIXEL (ximg, x, y); 4802 p->pixel = GET_PIXEL (ximg, x, y);
4798 if (rgb_p) 4803 if (rgb_p)
4799 { 4804 {
4800#if defined (HAVE_NS)
4801 p->red = RED16_FROM_ULONG (p->pixel); 4805 p->red = RED16_FROM_ULONG (p->pixel);
4802 p->green = GREEN16_FROM_ULONG (p->pixel); 4806 p->green = GREEN16_FROM_ULONG (p->pixel);
4803 p->blue = BLUE16_FROM_ULONG (p->pixel); 4807 p->blue = BLUE16_FROM_ULONG (p->pixel);
4804#endif /* HAVE_NS */
4805#ifdef HAVE_NTGUI
4806 p->red = 256 * GetRValue (p->pixel);
4807 p->green = 256 * GetGValue (p->pixel);
4808 p->blue = 256 * GetBValue (p->pixel);
4809#endif /* HAVE_NTGUI */
4810 } 4808 }
4811 } 4809 }
4812#endif /* HAVE_X_WINDOWS */ 4810#endif /* HAVE_X_WINDOWS */
@@ -6120,7 +6118,6 @@ png_load (f, img)
6120 if (STRINGP (specified_bg)) 6118 if (STRINGP (specified_bg))
6121 /* The user specified `:background', use that. */ 6119 /* The user specified `:background', use that. */
6122 { 6120 {
6123 /* W32 version incorrectly used COLORREF here!! ++kfs */
6124 XColor color; 6121 XColor color;
6125 if (x_defined_color (f, SDATA (specified_bg), &color, 0)) 6122 if (x_defined_color (f, SDATA (specified_bg), &color, 0))
6126 { 6123 {
@@ -6139,7 +6136,7 @@ png_load (f, img)
6139 { 6136 {
6140 /* We use the current frame background, ignoring any default 6137 /* We use the current frame background, ignoring any default
6141 background color set by the image. */ 6138 background color set by the image. */
6142#ifdef HAVE_X_WINDOWS 6139#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI)
6143 XColor color; 6140 XColor color;
6144 png_color_16 frame_background; 6141 png_color_16 frame_background;
6145 6142
@@ -6152,19 +6149,6 @@ png_load (f, img)
6152 frame_background.blue = color.blue >> shift; 6149 frame_background.blue = color.blue >> shift;
6153#endif /* HAVE_X_WINDOWS */ 6150#endif /* HAVE_X_WINDOWS */
6154 6151
6155#ifdef HAVE_NTGUI
6156 COLORREF color;
6157 png_color_16 frame_background;
6158 color = FRAME_BACKGROUND_PIXEL (f);
6159#if 0 /* W32 TODO : Colormap support. */
6160 x_query_color (f, &color);
6161#endif
6162 bzero (&frame_background, sizeof frame_background);
6163 frame_background.red = GetRValue (color);
6164 frame_background.green = GetGValue (color);
6165 frame_background.blue = GetBValue (color);
6166#endif /* HAVE_NTGUI */
6167
6168 fn_png_set_background (png_ptr, &frame_background, 6152 fn_png_set_background (png_ptr, &frame_background,
6169 PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); 6153 PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
6170 } 6154 }
@@ -8050,7 +8034,7 @@ svg_load_image (f, img, contents, size)
8050 gnome type library functions. */ 8034 gnome type library functions. */
8051 fn_g_type_init (); 8035 fn_g_type_init ();
8052 /* Make a handle to a new rsvg object. */ 8036 /* Make a handle to a new rsvg object. */
8053 rsvg_handle = fn_rsvg_handle_new (); 8037 rsvg_handle = (RsvgHandle *) fn_rsvg_handle_new ();
8054 8038
8055 /* Parse the contents argument and fill in the rsvg_handle. */ 8039 /* Parse the contents argument and fill in the rsvg_handle. */
8056 fn_rsvg_handle_write (rsvg_handle, contents, size, &error); 8040 fn_rsvg_handle_write (rsvg_handle, contents, size, &error);
@@ -8067,14 +8051,14 @@ svg_load_image (f, img, contents, size)
8067 8051
8068 /* We can now get a valid pixel buffer from the svg file, if all 8052 /* We can now get a valid pixel buffer from the svg file, if all
8069 went ok. */ 8053 went ok. */
8070 pixbuf = fn_rsvg_handle_get_pixbuf (rsvg_handle); 8054 pixbuf = (GdkPixbuf *) fn_rsvg_handle_get_pixbuf (rsvg_handle);
8071 if (!pixbuf) goto rsvg_error; 8055 if (!pixbuf) goto rsvg_error;
8072 fn_g_object_unref (rsvg_handle); 8056 fn_g_object_unref (rsvg_handle);
8073 8057
8074 /* Extract some meta data from the svg handle. */ 8058 /* Extract some meta data from the svg handle. */
8075 width = fn_gdk_pixbuf_get_width (pixbuf); 8059 width = fn_gdk_pixbuf_get_width (pixbuf);
8076 height = fn_gdk_pixbuf_get_height (pixbuf); 8060 height = fn_gdk_pixbuf_get_height (pixbuf);
8077 pixels = fn_gdk_pixbuf_get_pixels (pixbuf); 8061 pixels = (const guint8 *) fn_gdk_pixbuf_get_pixels (pixbuf);
8078 rowstride = fn_gdk_pixbuf_get_rowstride (pixbuf); 8062 rowstride = fn_gdk_pixbuf_get_rowstride (pixbuf);
8079 8063
8080 /* Validate the svg meta data. */ 8064 /* Validate the svg meta data. */
@@ -8104,7 +8088,6 @@ svg_load_image (f, img, contents, size)
8104 } 8088 }
8105 else 8089 else
8106 { 8090 {
8107#ifdef HAVE_X_WINDOWS
8108 background.pixel = FRAME_BACKGROUND_PIXEL (f); 8091 background.pixel = FRAME_BACKGROUND_PIXEL (f);
8109 x_query_color (f, &background); 8092 x_query_color (f, &background);
8110 8093
@@ -8114,21 +8097,6 @@ svg_load_image (f, img, contents, size)
8114 background.red >>= 8; 8097 background.red >>= 8;
8115 background.green >>= 8; 8098 background.green >>= 8;
8116 background.blue >>= 8; 8099 background.blue >>= 8;
8117#elif defined (HAVE_NTGUI)
8118 background.pixel = FRAME_BACKGROUND_PIXEL (f);
8119#if 0 /* W32 TODO : Colormap support. */
8120 x_query_color (f, &background);
8121#endif
8122
8123 /* SVG pixmaps specify transparency in the last byte, so right
8124 shift 8 bits to get rid of it, since emacs doesn't support
8125 transparency. */
8126 background.red >>= 8;
8127 background.green >>= 8;
8128 background.blue >>= 8;
8129#else /* not HAVE_X_WINDOWS*/
8130#error FIXME
8131#endif
8132 } 8100 }
8133 8101
8134 /* This loop handles opacity values, since Emacs assumes 8102 /* This loop handles opacity values, since Emacs assumes
diff --git a/src/w32term.c b/src/w32term.c
index f771427e548..eb7aebde881 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -1526,6 +1526,35 @@ w32_alloc_lighter_color (f, color, factor, delta)
1526 return 1; 1526 return 1;
1527} 1527}
1528 1528
1529/* On frame F, translate pixel colors to RGB values for the NCOLORS
1530 colors in COLORS. On W32, we no longer try to map colors to
1531 a palette. */
1532void
1533x_query_colors (f, colors, ncolors)
1534 struct frame *f;
1535 XColor *colors;
1536 int ncolors;
1537{
1538 int i;
1539
1540 for (i = 0; i < ncolors; i++)
1541 {
1542 DWORD pixel = colors[i].pixel;
1543 /* Convert to a 16 bit value in range 0 - 0xffff. */
1544 colors[i].red = GetRValue (pixel) * 257;
1545 colors[i].green = GetGValue (pixel) * 257;
1546 colors[i].blue = GetBValue (pixel) * 257;
1547 }
1548}
1549
1550void
1551x_query_color (f, color)
1552 struct frame *f;
1553 XColor *color;
1554{
1555 x_query_colors (f, color, 1);
1556}
1557
1529 1558
1530/* Set up the foreground color for drawing relief lines of glyph 1559/* Set up the foreground color for drawing relief lines of glyph
1531 string S. RELIEF is a pointer to a struct relief containing the GC 1560 string S. RELIEF is a pointer to a struct relief containing the GC