]> Pileus Git - ~andy/gtk/blobdiff - gdk/gdkrgb.c
nparams for selection_get should be 3, not 2. [ From Damon Chaplin
[~andy/gtk] / gdk / gdkrgb.c
index becabbb20ebda4f2a2dd88c9d993476589b51d76..51c14399a56fe19c5bb2dc052654bcf3086de274 100644 (file)
    */
 
 #include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
+
+#if HAVE_CONFIG_H
+#  include <config.h>
+#  if STDC_HEADERS
+#    include <stdio.h>
+#    include <stdlib.h>
+#    include <string.h>
+#  endif
+#else
+#  include <stdio.h>
+#  include <stdlib.h>
+#endif
+
 
 #define ENABLE_GRAYSCALE
 
@@ -304,7 +315,7 @@ gdk_rgb_try_colormap (gint nr, gint ng, gint nb)
 static gboolean
 gdk_rgb_do_colormaps (void)
 {
-  const gint sizes[][3] = {
+  static const gint sizes[][3] = {
     /*    { 6, 7, 6 }, */
     { 6, 6, 6 }, 
     { 6, 6, 5 }, 
@@ -316,7 +327,7 @@ gdk_rgb_do_colormaps (void)
     { 3, 3, 3 }, 
     { 2, 2, 2 }
   };
-  const gint n_sizes = sizeof(sizes) / (3 * sizeof(gint));
+  static const gint n_sizes = sizeof(sizes) / (3 * sizeof(gint));
   gint i;
 
   for (i = 0; i < n_sizes; i++)
@@ -387,7 +398,7 @@ static guint32
 gdk_rgb_score_visual (GdkVisual *visual)
 {
   guint32 quality, speed, sys, pseudo;
-  gchar* visual_names[] =
+  static const gchar* visual_names[] =
   {
     "static gray",
     "grayscale",
@@ -535,15 +546,15 @@ void
 gdk_rgb_init (void)
 {
   gint i;
-  gint byte_order[1] = { 1 };
+  static const gint byte_order[1] = { 1 };
 
   /* check endian sanity */
-#ifdef WORDS_BIGENDIAN
+#if G_BYTE_ORDER == G_BIG_ENDIAN
   if (((char *)byte_order)[0] == 1)
-    g_error ("gdk_rgb_init: WORDS_BIGENDIAN is defined, but this is a little endian machine.\n\n");
+    g_error ("gdk_rgb_init: compiled for big endian, but this is a little endian machine.\n\n");
 #else
   if (((char *)byte_order)[0] != 1)
-    g_error ("gdk_rgb_init: WORDS_BIGENDIAN is not defined, but this is a big endian machine.\n\n");
+    g_error ("gdk_rgb_init: compiled for little endian, but this is a big endian machine.\n\n");
 #endif
 
   if (image_info == NULL)
@@ -631,7 +642,7 @@ gdk_rgb_init (void)
        if (image_info->bitmap)
          /* Use malloc() instead of g_malloc since X will free() this mem */
          static_image[i] = gdk_image_new_bitmap (image_info->visual,
-                                                 malloc (IMAGE_WIDTH * IMAGE_HEIGHT >> 3),
+                                                 (gpointer) malloc (IMAGE_WIDTH * IMAGE_HEIGHT >> 3),
                                                  IMAGE_WIDTH, IMAGE_HEIGHT);
        else
          static_image[i] = gdk_image_new (GDK_IMAGE_FASTEST,
@@ -649,7 +660,7 @@ gdk_rgb_init (void)
 gulong
 gdk_rgb_xpixel_from_rgb (guint32 rgb)
 {
-  gulong pixel;
+  gulong pixel = 0;
 
   if (image_info->bitmap)
     {
@@ -722,7 +733,7 @@ gdk_rgb_gc_set_background (GdkGC *gc, guint32 rgb)
   gdk_gc_set_background (gc, &color);
 }
 
-#ifndef WORDS_BIGENDIAN
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
 #define HAIRY_CONVERT_8
 #endif
 
@@ -846,7 +857,7 @@ gdk_rgb_convert_8 (GdkImage *image,
 #define DM_WIDTH 128
 #define DM_WIDTH_SHIFT 7
 #define DM_HEIGHT 128
-static guchar DM[128][128] =
+static const guchar DM[128][128] =
 {
   { 0, 41, 23, 5, 17, 39, 7, 15, 62, 23, 40, 51, 31, 47, 9, 32, 52, 27, 57, 25, 6, 61, 27, 52, 37, 7, 40, 63, 18, 36, 10, 42, 25, 62, 45, 34, 20, 42, 37, 14, 35, 29, 50, 10, 61, 2, 40, 8, 37, 12, 58, 22, 5, 41, 10, 39, 0, 60, 11, 46, 2, 55, 38, 17, 36, 59, 13, 54, 37, 56, 8, 29, 16, 13, 63, 22, 41, 55, 7, 20, 49, 14, 23, 55, 37, 23, 19, 36, 15, 49, 23, 63, 30, 14, 38, 27, 53, 13, 22, 41, 19, 31, 7, 19, 50, 30, 49, 16, 3, 32, 56, 40, 29, 34, 8, 48, 19, 45, 4, 51, 12, 46, 35, 49, 16, 42, 12, 62 },
   { 30, 57, 36, 54, 47, 34, 52, 27, 43, 4, 28, 7, 17, 36, 62, 13, 44, 7, 18, 48, 33, 21, 44, 14, 30, 47, 12, 33, 5, 55, 31, 58, 13, 30, 4, 17, 52, 10, 60, 26, 46, 0, 39, 27, 42, 22, 47, 25, 60, 32, 9, 38, 48, 17, 59, 30, 49, 18, 34, 25, 51, 19, 5, 48, 21, 8, 28, 46, 1, 32, 41, 19, 54, 47, 37, 18, 28, 11, 44, 30, 39, 56, 2, 33, 8, 42, 61, 28, 58, 8, 46, 9, 41, 4, 58, 7, 21, 48, 59, 10, 52, 14, 42, 57, 12, 25, 7, 53, 42, 24, 11, 50, 17, 59, 42, 2, 36, 60, 32, 17, 63, 29, 21, 7, 59, 32, 24, 39 },
@@ -982,7 +993,7 @@ static guchar DM[128][128] =
 #define DM_WIDTH 8
 #define DM_WIDTH_SHIFT 3
 #define DM_HEIGHT 8
-static guchar DM[8][8] =
+static const guchar DM[8][8] =
 {
   { 0,  32, 8,  40, 2,  34, 10, 42 },
   { 48, 16, 56, 24, 50, 18, 58, 26 },
@@ -1028,7 +1039,7 @@ gdk_rgb_convert_8_d666 (GdkImage *image,
   guchar *obuf, *obptr;
   guchar *bptr, *bp2;
   gint r, g, b;
-  guchar *dmp;
+  const guchar *dmp;
   gint dith;
 
   bptr = buf;
@@ -1068,7 +1079,7 @@ gdk_rgb_convert_8_d (GdkImage *image,
   guchar *obuf, *obptr;
   guchar *bptr, *bp2;
   gint r, g, b;
-  guchar *dmp;
+  const guchar *dmp;
   gint dith;
   gint rs, gs, bs;
 
@@ -1186,7 +1197,7 @@ gdk_rgb_convert_gray8_gray (GdkImage *image,
     }
 }
 
-#ifndef WORDS_BIGENDIAN
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
 #define HAIRY_CONVERT_565
 #endif
 
@@ -1729,7 +1740,7 @@ gdk_rgb_convert_888_msb (GdkImage *image,
 }
 
 /* todo: optimize this */
-#ifndef WORDS_BIGENDIAN
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
 #define HAIRY_CONVERT_888
 #endif
 
@@ -1867,7 +1878,7 @@ gdk_rgb_convert_0888 (GdkImage *image,
          r = bp2[0];
          g = bp2[1];
          b = bp2[2];
-         ((unsigned long *)obuf)[x] = (r << 16) | (g << 8) | b;
+         ((guint32 *)obuf)[x] = (r << 16) | (g << 8) | b;
          bp2 += 3;
        }
       bptr += rowstride;
@@ -1898,7 +1909,7 @@ gdk_rgb_convert_0888_br (GdkImage *image,
          r = bp2[0];
          g = bp2[1];
          b = bp2[2];
-         ((unsigned long *)obuf)[x] = (b << 24) | (g << 16) | (r << 8);
+         ((guint32 *)obuf)[x] = (b << 24) | (g << 16) | (r << 8);
          bp2 += 3;
        }
       bptr += rowstride;
@@ -1929,7 +1940,7 @@ gdk_rgb_convert_8880_br (GdkImage *image,
          r = bp2[0];
          g = bp2[1];
          b = bp2[2];
-         ((unsigned long *)obuf)[x] = (b << 16) | (g << 8) | r;
+         ((guint32 *)obuf)[x] = (b << 16) | (g << 8) | r;
          bp2 += 3;
        }
       bptr += rowstride;
@@ -2012,7 +2023,7 @@ gdk_rgb_convert_truecolor_lsb_d (GdkImage *image,
   gint i;
   gint dith;
   gint r1, g1, b1;
-  guchar *dmp;
+  const guchar *dmp;
 
   r_right = 8 - image_info->visual->red_prec;
   r_left = image_info->visual->red_shift;
@@ -2129,7 +2140,7 @@ gdk_rgb_convert_truecolor_msb_d (GdkImage *image,
   gint shift, shift_init;
   gint dith;
   gint r1, g1, b1;
-  guchar *dmp;
+  const guchar *dmp;
 
   r_right = 8 - image_info->visual->red_prec;
   r_left = image_info->visual->red_shift;
@@ -2186,7 +2197,7 @@ gdk_rgb_convert_4 (GdkImage *image,
   guchar *obuf, *obptr;
   guchar *bptr, *bp2;
   gint r, g, b;
-  guchar *dmp;
+  const guchar *dmp;
   gint dith;
 
   bptr = buf;
@@ -2309,7 +2320,7 @@ gdk_rgb_convert_gray4_d (GdkImage *image,
   guchar *obuf, *obptr;
   guchar *bptr, *bp2;
   gint r, g, b;
-  guchar *dmp;
+  const guchar *dmp;
   gint prec, right;
   gint gray;
 
@@ -2349,7 +2360,7 @@ gdk_rgb_convert_gray4_d_pack (GdkImage *image,
   guchar *obuf, *obptr;
   guchar *bptr, *bp2;
   gint r, g, b;
-  guchar *dmp;
+  const guchar *dmp;
   gint prec, right;
   gint gray;
   guchar pix0, pix1;
@@ -2409,7 +2420,7 @@ gdk_rgb_convert_1 (GdkImage *image,
   guchar *obuf, *obptr;
   guchar *bptr, *bp2;
   gint r, g, b;
-  guchar *dmp;
+  const guchar *dmp;
   gint dith;
   guchar byte;
 
@@ -2668,7 +2679,7 @@ gdk_rgb_select_conv (GdkImage *image)
             (gint)(((GdkVisualPrivate *)image_info->visual)->xvisual->visualid),
             bpp, byte_order == GDK_LSB_FIRST ? "lsb" : "msb");
 
-#ifdef WORDS_BIGENDIAN
+#if G_BYTE_ORDER == G_BIG_ENDIAN
   byterev = (byte_order == GDK_LSB_FIRST);
 #else
   byterev = (byte_order == GDK_MSB_FIRST);
@@ -2733,7 +2744,7 @@ gdk_rgb_select_conv (GdkImage *image)
           ((mask_rgb && byte_order == GDK_MSB_FIRST) ||
            (mask_bgr && byte_order == GDK_LSB_FIRST)))
     conv = gdk_rgb_convert_888_msb;
-#ifdef WORDS_BIGENDIAN
+#if G_BYTE_ORDER == G_BIG_ENDIAN
   else if (bpp == 32 && depth == 24 && vtype == GDK_VISUAL_TRUE_COLOR &&
           (mask_rgb && byte_order == GDK_LSB_FIRST))
     conv = gdk_rgb_convert_0888_br;