]> Pileus Git - ~andy/gtk/blobdiff - gdk/gdkpixbuf-drawable.c
update packaging script for current tutorial
[~andy/gtk] / gdk / gdkpixbuf-drawable.c
index 0a4474969d1edf5c3c4ba275be0b4535d0f648eb..ec7d650a7aa8f3226b0055b5ab77251a63ef05a4 100644 (file)
@@ -437,14 +437,15 @@ rgb565lsb (GdkImage    *image,
            | (data & 0x1f0000) >> 5 | (data & 0x1c0000) >> 10;
 #else
          /* swap endianness first */
-         data = s[1] | s[0] << 8 | s[3] << 16 | s[2] << 24;
+         data = s[1] << 24 | s[0] << 16 | s[3] << 8 | s[2];
          s += 4;
-         *o++ = (data & 0xf800) | (data & 0xe000) >> 5
-           | (data & 0x7e0) >> 3 | (data & 0x600) >> 9;
-         *o++ = (data & 0x1f) << 11 | (data & 0x1c) << 6
-           | (data & 0xf8000000) >> 24 | (data & 0xe0000000) >> 29;
-         *o++ = (data & 0x7e00000) >> 11 | (data & 0x6000000) >> 17
-           | (data & 0x1f0000) >> 13 | (data & 0x1c0000) >> 18;
+
+         *o++ = (data & 0xf8000000) >> 16 | (data & 0xe0000000) >> 21
+           | (data & 0x7e00000) >> 19 | (data & 0x6000000) >> 25;
+         *o++ = (data & 0x1f0000) >> 5 | (data & 0x1c0000) >> 10
+           | (data & 0xf800) >> 8 | (data & 0xe000) >> 13;
+         *o++ = (data & 0x7e0) << 5 | (data & 0x600) >> 1
+           | (data & 0x1f) << 3 | (data & 0x1c) >> 2;
 #endif
        }
       /* check for last remaining pixel */
@@ -544,12 +545,12 @@ rgb565msb (GdkImage    *image,
            | (data & 0x1f0000) >> 5 | (data & 0x1c0000) >> 10;
 #else
          data = *s++;
-         *o++ = (data & 0xf800) | (data & 0xe000) >> 5
-           | (data & 0x7e0) >> 3 | (data & 0x600) >> 9;
-         *o++ = (data & 0x1f) << 11 | (data & 0x1c) << 6
-           | (data & 0xf8000000) >> 24 | (data & 0xe0000000) >> 29;
-         *o++ = (data & 0x7e00000) >> 11 | (data & 0x6000000) >> 17
-           | (data & 0x1f0000) >> 13 | (data & 0x1c0000) >> 18;
+         *o++ = (data & 0xf8000000) >> 16 | (data & 0xe0000000) >> 21
+           | (data & 0x7e00000) >> 19 | (data & 0x6000000) >> 25;
+         *o++ = (data & 0x1f0000) >> 5 | (data & 0x1c0000) >> 10
+           | (data & 0xf800) >> 8 | (data & 0xe000) >> 13;
+         *o++ = (data & 0x7e0) << 5 | (data & 0x600) >> 1
+           | (data & 0x1f) << 3 | (data & 0x1c) >> 2;
 #endif
        }
       /* check for last remaining pixel */
@@ -1217,6 +1218,14 @@ convert_real_slow (GdkImage    *image,
   bpl = image->bpl;
   v = gdk_colormap_get_visual(cmap);
 
+  if (image->depth != v->depth)
+    {
+      g_warning ("%s: The depth of the source image (%d) doesn't "
+                 "match the depth of the colormap passed in (%d).",
+                 G_STRLOC, image->depth, v->depth);
+      return;
+    } 
   d(printf("rgb  mask/shift/prec = %x:%x:%x %d:%d:%d  %d:%d:%d\n",
           v->red_mask, v->green_mask, v->blue_mask,
           v->red_shift, v->green_shift, v->blue_shift,
@@ -1328,6 +1337,15 @@ rgbconvert (GdkImage    *image,
     }
   
   v = gdk_colormap_get_visual (cmap);
+
+  if (image->depth != v->depth)
+    {
+      g_warning ("%s: The depth of the source image (%d) doesn't "
+                 "match the depth of the colormap passed in (%d).",
+                 G_STRLOC, image->depth, v->depth);
+      return;
+    } 
   bank = 5; /* default fallback converter */
   index = (image->byte_order == GDK_MSB_FIRST) | (alpha != 0) << 1;
   
@@ -1514,6 +1532,14 @@ gdk_pixbuf_get_from_drawable (GdkPixbuf   *dest,
       return NULL;
     }
   
+  if (cmap != NULL && depth != cmap->visual->depth)
+    {
+      g_warning ("%s: Depth of the source drawable is %d where as "
+                 "the visual depth of the colormap passed is %d",
+                 G_STRLOC, depth, cmap->visual->depth);
+      return NULL;
+    } 
   /* Coordinate sanity checks */
   
   if (GDK_IS_PIXMAP (src))
@@ -1622,6 +1648,14 @@ gdk_pixbuf_get_from_image (GdkPixbuf   *dest,
       return NULL;
     }
   
+  if (cmap != NULL && src->depth != cmap->visual->depth)
+    {
+      g_warning ("%s: Depth of the Source image is %d where as "
+                 "the visual depth of the colormap passed is %d",
+                 G_STRLOC, src->depth, cmap->visual->depth);
+      return NULL;
+    } 
   /* Coordinate sanity checks */
 
   g_return_val_if_fail (src_x >= 0 && src_y >= 0, NULL);