*/
#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
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 },
{ 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++)
gdk_rgb_score_visual (GdkVisual *visual)
{
guint32 quality, speed, sys, pseudo;
- gchar* visual_names[] =
+ static const gchar* visual_names[] =
{
"static gray",
"grayscale",
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)
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,
gulong
gdk_rgb_xpixel_from_rgb (guint32 rgb)
{
- gulong pixel;
+ gulong pixel = 0;
if (image_info->bitmap)
{
gdk_gc_set_background (gc, &color);
}
-#ifndef WORDS_BIGENDIAN
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define HAIRY_CONVERT_8
#endif
#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 },
#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 },
guchar *obuf, *obptr;
guchar *bptr, *bp2;
gint r, g, b;
- guchar *dmp;
+ const guchar *dmp;
gint dith;
bptr = buf;
guchar *obuf, *obptr;
guchar *bptr, *bp2;
gint r, g, b;
- guchar *dmp;
+ const guchar *dmp;
gint dith;
gint rs, gs, bs;
}
}
-#ifndef WORDS_BIGENDIAN
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define HAIRY_CONVERT_565
#endif
}
/* todo: optimize this */
-#ifndef WORDS_BIGENDIAN
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define HAIRY_CONVERT_888
#endif
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;
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;
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;
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;
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;
guchar *obuf, *obptr;
guchar *bptr, *bp2;
gint r, g, b;
- guchar *dmp;
+ const guchar *dmp;
gint dith;
bptr = buf;
guchar *obuf, *obptr;
guchar *bptr, *bp2;
gint r, g, b;
- guchar *dmp;
+ const guchar *dmp;
gint prec, right;
gint gray;
guchar *obuf, *obptr;
guchar *bptr, *bp2;
gint r, g, b;
- guchar *dmp;
+ const guchar *dmp;
gint prec, right;
gint gray;
guchar pix0, pix1;
guchar *obuf, *obptr;
guchar *bptr, *bp2;
gint r, g, b;
- guchar *dmp;
+ const guchar *dmp;
gint dith;
guchar byte;
(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);
((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;