emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs/src ChangeLog image.c w32term.c


From: Jason Rumney
Subject: [Emacs-diffs] emacs/src ChangeLog image.c w32term.c
Date: Sat, 03 Jan 2009 11:16:34 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Jason Rumney <jasonr>   09/01/03 11:16:34

Modified files:
        src            : ChangeLog image.c w32term.c 

Log message:
        * 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.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/src/ChangeLog?cvsroot=emacs&r1=1.7249&r2=1.7250
http://cvs.savannah.gnu.org/viewcvs/emacs/src/image.c?cvsroot=emacs&r1=1.116&r2=1.117
http://cvs.savannah.gnu.org/viewcvs/emacs/src/w32term.c?cvsroot=emacs&r1=1.314&r2=1.315

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/src/ChangeLog,v
retrieving revision 1.7249
retrieving revision 1.7250
diff -u -b -r1.7249 -r1.7250
--- ChangeLog   2 Jan 2009 18:58:49 -0000       1.7249
+++ ChangeLog   3 Jan 2009 11:16:32 -0000       1.7250
@@ -1,3 +1,11 @@
+2009-01-03  Jason Rumney  <address@hidden>
+
+       * 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.
+
 2009-01-02  Dan Nicolaescu  <address@hidden>
 
        * nsfns.m (x_set_foreground_color, x_set_background_color)

Index: image.c
===================================================================
RCS file: /sources/emacs/emacs/src/image.c,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -b -r1.116 -r1.117
--- image.c     2 Jan 2009 12:10:21 -0000       1.116
+++ image.c     3 Jan 2009 11:16:33 -0000       1.117
@@ -79,6 +79,11 @@
 #define FRAME_X_VISUAL(f) FRAME_X_DISPLAY_INFO (f)->visual
 #define x_defined_color w32_defined_color
 #define DefaultDepthOfScreen(screen) (one_w32_display_info.n_cbits)
+
+/* Functions from w32term.c that depend on XColor (so can't go in w32term.h
+   without modifying lots of files).  */
+extern void x_query_colors (struct frame *f, XColor *colors, int ncolors);
+extern void x_query_color (struct frame *f, XColor *color);
 #endif /* HAVE_NTGUI */
 
 #ifdef HAVE_NS
@@ -4783,9 +4788,9 @@
     {
       XColor *row = p;
 
-#ifdef HAVE_X_WINDOWS
+#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI)
       for (x = 0; x < img->width; ++x, ++p)
-       p->pixel = XGetPixel (ximg, x, y);
+       p->pixel = GET_PIXEL (ximg, x, y);
       if (rgb_p)
        x_query_colors (f, row, img->width);
 
@@ -4797,16 +4802,9 @@
          p->pixel = GET_PIXEL (ximg, x, y);
          if (rgb_p)
            {
-#if defined (HAVE_NS)
              p->red = RED16_FROM_ULONG (p->pixel);
              p->green = GREEN16_FROM_ULONG (p->pixel);
              p->blue = BLUE16_FROM_ULONG (p->pixel);
-#endif  /* HAVE_NS */
-#ifdef HAVE_NTGUI
-             p->red = 256 * GetRValue (p->pixel);
-             p->green = 256 * GetGValue (p->pixel);
-             p->blue = 256 * GetBValue (p->pixel);
-#endif /* HAVE_NTGUI */
            }
        }
 #endif /* HAVE_X_WINDOWS */
@@ -6120,7 +6118,6 @@
       if (STRINGP (specified_bg))
        /* The user specified `:background', use that.  */
        {
-         /* W32 version incorrectly used COLORREF here!!  ++kfs */
          XColor color;
          if (x_defined_color (f, SDATA (specified_bg), &color, 0))
            {
@@ -6139,7 +6136,7 @@
        {
          /* We use the current frame background, ignoring any default
             background color set by the image.  */
-#ifdef HAVE_X_WINDOWS
+#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI)
          XColor color;
          png_color_16 frame_background;
 
@@ -6152,19 +6149,6 @@
          frame_background.blue = color.blue >> shift;
 #endif /* HAVE_X_WINDOWS */
 
-#ifdef HAVE_NTGUI
-         COLORREF color;
-         png_color_16 frame_background;
-         color = FRAME_BACKGROUND_PIXEL (f);
-#if 0 /* W32 TODO : Colormap support.  */
-         x_query_color (f, &color);
-#endif
-         bzero (&frame_background, sizeof frame_background);
-         frame_background.red = GetRValue (color);
-         frame_background.green = GetGValue (color);
-         frame_background.blue = GetBValue (color);
-#endif /* HAVE_NTGUI */
-
          fn_png_set_background (png_ptr, &frame_background,
                                 PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
        }
@@ -8050,7 +8034,7 @@
      gnome type library functions.  */
   fn_g_type_init ();
   /* Make a handle to a new rsvg object.  */
-  rsvg_handle = fn_rsvg_handle_new ();
+  rsvg_handle = (RsvgHandle *) fn_rsvg_handle_new ();
 
   /* Parse the contents argument and fill in the rsvg_handle.  */
   fn_rsvg_handle_write (rsvg_handle, contents, size, &error);
@@ -8067,14 +8051,14 @@
 
   /* We can now get a valid pixel buffer from the svg file, if all
      went ok.  */
-  pixbuf = fn_rsvg_handle_get_pixbuf (rsvg_handle);
+  pixbuf = (GdkPixbuf *) fn_rsvg_handle_get_pixbuf (rsvg_handle);
   if (!pixbuf) goto rsvg_error;
   fn_g_object_unref (rsvg_handle);
 
   /* Extract some meta data from the svg handle.  */
   width     = fn_gdk_pixbuf_get_width (pixbuf);
   height    = fn_gdk_pixbuf_get_height (pixbuf);
-  pixels    = fn_gdk_pixbuf_get_pixels (pixbuf);
+  pixels    = (const guint8 *) fn_gdk_pixbuf_get_pixels (pixbuf);
   rowstride = fn_gdk_pixbuf_get_rowstride (pixbuf);
 
   /* Validate the svg meta data.  */
@@ -8104,21 +8088,8 @@
     }
   else
     {
-#ifdef HAVE_X_WINDOWS
-      background.pixel = FRAME_BACKGROUND_PIXEL (f);
-      x_query_color (f, &background);
-
-      /* SVG pixmaps specify transparency in the last byte, so right
-        shift 8 bits to get rid of it, since emacs doesn't support
-        transparency.  */
-      background.red   >>= 8;
-      background.green >>= 8;
-      background.blue  >>= 8;
-#elif defined (HAVE_NTGUI)
       background.pixel = FRAME_BACKGROUND_PIXEL (f);
-#if 0 /* W32 TODO : Colormap support.  */
       x_query_color (f, &background);
-#endif
 
       /* SVG pixmaps specify transparency in the last byte, so right
         shift 8 bits to get rid of it, since emacs doesn't support
@@ -8126,9 +8097,6 @@
       background.red   >>= 8;
       background.green >>= 8;
       background.blue  >>= 8;
-#else /* not HAVE_X_WINDOWS*/
-#error FIXME
-#endif
     }
 
   /* This loop handles opacity values, since Emacs assumes

Index: w32term.c
===================================================================
RCS file: /sources/emacs/emacs/src/w32term.c,v
retrieving revision 1.314
retrieving revision 1.315
diff -u -b -r1.314 -r1.315
--- w32term.c   1 Jan 2009 02:05:39 -0000       1.314
+++ w32term.c   3 Jan 2009 11:16:34 -0000       1.315
@@ -1526,6 +1526,35 @@
   return 1;
 }
 
+/* On frame F, translate pixel colors to RGB values for the NCOLORS
+   colors in COLORS.  On W32, we no longer try to map colors to
+   a palette.  */
+void
+x_query_colors (f, colors, ncolors)
+     struct frame *f;
+     XColor *colors;
+     int ncolors;
+{
+  int i;
+
+  for (i = 0; i < ncolors; i++)
+    {
+      DWORD pixel = colors[i].pixel;
+      /* Convert to a 16 bit value in range 0 - 0xffff. */
+      colors[i].red = GetRValue (pixel) * 257;
+      colors[i].green = GetGValue (pixel) * 257;
+      colors[i].blue = GetBValue (pixel) * 257;
+    }
+}
+
+void
+x_query_color (f, color)
+     struct frame *f;
+     XColor *color;
+{
+  x_query_colors (f, color, 1);
+}
+
 
 /* Set up the foreground color for drawing relief lines of glyph
    string S.  RELIEF is a pointer to a struct relief containing the GC




reply via email to

[Prev in Thread] Current Thread [Next in Thread]