summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
Diffstat (limited to 'gdk')
-rw-r--r--gdk/gdkcolor.c8
-rw-r--r--gdk/gdkrgb.c419
-rw-r--r--gdk/gdkrgb.h13
-rw-r--r--gdk/gdkwindow.c1
-rw-r--r--gdk/x11/gdkcolor-x11.c8
-rw-r--r--gdk/x11/gdkwindow-x11.c1
6 files changed, 388 insertions, 62 deletions
diff --git a/gdk/gdkcolor.c b/gdk/gdkcolor.c
index fa810473e6..36b6c8593c 100644
--- a/gdk/gdkcolor.c
+++ b/gdk/gdkcolor.c
@@ -71,8 +71,8 @@ gdk_colormap_new (GdkVisual *visual,
private->info = g_new0 (GdkColorInfo, colormap->size);
colormap->colors = g_new (GdkColor, colormap->size);
- private->hash = g_hash_table_new (gdk_color_hash,
- gdk_color_equal);
+ private->hash = g_hash_table_new ((GHashFunc) gdk_color_hash,
+ (GCompareFunc) gdk_color_equal);
private->private_val = private_cmap;
private->xcolormap = XCreateColormap (private->xdisplay, gdk_root_window,
@@ -259,8 +259,8 @@ gdk_colormap_get_system (void)
private->info = g_new0 (GdkColorInfo, colormap->size);
colormap->colors = g_new (GdkColor, colormap->size);
- private->hash = g_hash_table_new (gdk_color_hash,
- gdk_color_equal);
+ private->hash = g_hash_table_new ((GHashFunc) gdk_color_hash,
+ (GCompareFunc) gdk_color_equal);
gdk_colormap_sync (colormap, TRUE);
}
diff --git a/gdk/gdkrgb.c b/gdk/gdkrgb.c
index a4f11de5d9..e91e4c514e 100644
--- a/gdk/gdkrgb.c
+++ b/gdk/gdkrgb.c
@@ -87,6 +87,9 @@ struct _GdkRgbInfo
gboolean dith_default;
+ gboolean bitmap; /* set true if in 1 bit per pixel mode */
+ GdkGC *own_gc;
+
/* Convert functions */
GdkRgbConvFunc conv;
GdkRgbConvFunc conv_d;
@@ -539,7 +542,7 @@ gdk_rgb_init (void)
g_error ("gdk_rgb_init: WORDS_BIGENDIAN is defined, 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 little endian machine.\n\n");
+ g_error ("gdk_rgb_init: WORDS_BIGENDIAN is not defined, but this is a big endian machine.\n\n");
#endif
if (image_info == NULL)
@@ -565,10 +568,16 @@ gdk_rgb_init (void)
image_info->stage_buf = NULL;
+ image_info->own_gc = NULL;
+
gdk_rgb_choose_visual ();
- if (image_info->visual->depth == 4)
+ if ((image_info->visual->type == GDK_VISUAL_PSEUDO_COLOR ||
+ image_info->visual->type == GDK_VISUAL_STATIC_COLOR) &&
+ image_info->visual->depth < 8 &&
+ image_info->visual->depth >= 3)
{
+ image_info->cmap = gdk_colormap_get_system ();
gdk_rgb_colorcube_222 ();
}
else if (image_info->visual->type == GDK_VISUAL_PSEUDO_COLOR)
@@ -615,10 +624,17 @@ gdk_rgb_init (void)
}
}
+ image_info->bitmap = (image_info->visual->depth == 1);
+
for (i = 0; i < N_IMAGES; i++)
- static_image[i] = gdk_image_new (GDK_IMAGE_FASTEST,
- image_info->visual,
- IMAGE_WIDTH, IMAGE_HEIGHT);
+ if (image_info->bitmap)
+ static_image[i] = gdk_image_new_bitmap (image_info->visual,
+ g_malloc (IMAGE_WIDTH * IMAGE_HEIGHT >> 3),
+ IMAGE_WIDTH, IMAGE_HEIGHT);
+ else
+ static_image[i] = gdk_image_new (GDK_IMAGE_FASTEST,
+ image_info->visual,
+ IMAGE_WIDTH, IMAGE_HEIGHT);
image_info->bpp = static_image[0]->bpp;
@@ -637,7 +653,7 @@ gdk_rgb_xpixel_from_rgb (guint32 rgb)
pixel = colorcube[((rgb & 0xf00000) >> 12) |
((rgb & 0xf000) >> 8) |
((rgb & 0xf0) >> 4)];
- else if (image_info->visual->depth == 4 &&
+ else if (image_info->visual->depth < 8 &&
image_info->visual->type == GDK_VISUAL_STATIC_COLOR)
{
pixel = colorcube_d[((rgb & 0x800000) >> 17) |
@@ -1872,6 +1888,37 @@ gdk_rgb_convert_0888_br (GdkImage *image,
}
}
+static void
+gdk_rgb_convert_8880_br (GdkImage *image,
+ gint x0, gint y0, gint width, gint height,
+ guchar *buf, int rowstride,
+ gint x_align, gint y_align, GdkRgbCmap *cmap)
+{
+ int x, y;
+ guchar *obuf;
+ gint bpl;
+ guchar *bptr, *bp2;
+ int r, g, b;
+
+ bptr = buf;
+ bpl = image->bpl;
+ obuf = ((guchar *)image->mem) + y0 * bpl + x0 * 4;
+ for (y = 0; y < height; y++)
+ {
+ bp2 = bptr;
+ for (x = 0; x < width; x++)
+ {
+ r = bp2[0];
+ g = bp2[1];
+ b = bp2[2];
+ ((unsigned long *)obuf)[x] = (b << 16) | (g << 8) | r;
+ bp2 += 3;
+ }
+ bptr += rowstride;
+ obuf += bpl;
+ }
+}
+
/* Generic truecolor/directcolor conversion function. Slow, but these
are oddball modes. */
static void
@@ -2108,7 +2155,7 @@ gdk_rgb_convert_truecolor_msb_d (GdkImage *image,
}
}
-#define IMAGE_8BPP
+/* This actually works for depths from 3 to 7 */
static void
gdk_rgb_convert_4 (GdkImage *image,
gint x0, gint y0, gint width, gint height,
@@ -2132,7 +2179,6 @@ gdk_rgb_convert_4 (GdkImage *image,
dmp = DM[(y_align + y) & (DM_HEIGHT - 1)];
bp2 = bptr;
obptr = obuf;
-#ifdef IMAGE_8BPP
for (x = 0; x < width; x += 1)
{
r = *bp2++;
@@ -2144,32 +2190,221 @@ gdk_rgb_convert_4 (GdkImage *image,
(((b + dith) & 0x100) >> 8)];
obptr++;
}
-#else
+ bptr += rowstride;
+ obuf += bpl;
+ }
+}
+
+/* This actually works for depths from 3 to 7 */
+static void
+gdk_rgb_convert_gray4 (GdkImage *image,
+ gint x0, gint y0, gint width, gint height,
+ guchar *buf, int rowstride,
+ gint x_align, gint y_align, GdkRgbCmap *cmap)
+{
+ int x, y;
+ gint bpl;
+ guchar *obuf, *obptr;
+ guchar *bptr, *bp2;
+ gint r, g, b;
+ gint shift;
+
+ bptr = buf;
+ bpl = image->bpl;
+ obuf = ((guchar *)image->mem) + y0 * bpl + x0;
+ shift = 9 - image_info->visual->depth;
+ for (y = 0; y < height; y++)
+ {
+ bp2 = bptr;
+ obptr = obuf;
+ for (x = 0; x < width; x++)
+ {
+ r = *bp2++;
+ g = *bp2++;
+ b = *bp2++;
+ obptr[0] = (g + ((b + r) >> 1)) >> shift;
+ obptr++;
+ }
+ bptr += rowstride;
+ obuf += bpl;
+ }
+}
+
+static void
+gdk_rgb_convert_gray4_pack (GdkImage *image,
+ gint x0, gint y0, gint width, gint height,
+ guchar *buf, int rowstride,
+ gint x_align, gint y_align, GdkRgbCmap *cmap)
+{
+ int x, y;
+ gint bpl;
+ guchar *obuf, *obptr;
+ guchar *bptr, *bp2;
+ gint r, g, b;
+ gint shift;
+ guchar pix0, pix1;
+ /* todo: this is hardcoded to big-endian. Make endian-agile. */
+
+ bptr = buf;
+ bpl = image->bpl;
+ obuf = ((guchar *)image->mem) + y0 * bpl + (x0 >> 1);
+ shift = 9 - image_info->visual->depth;
+ for (y = 0; y < height; y++)
+ {
+ bp2 = bptr;
+ obptr = obuf;
for (x = 0; x < width; x += 2)
{
r = *bp2++;
g = *bp2++;
b = *bp2++;
- dith = (dmp[(x_align + x) & (DM_WIDTH - 1)] << 2) | 3;
- pix0 = colorcube_d[(((r + dith) & 0x100) >> 2) |
- (((g + dith) & 0x100) >> 5) |
- (((b + dith) & 0x100) >> 8)];
+ pix0 = (g + ((b + r) >> 1)) >> shift;
r = *bp2++;
g = *bp2++;
b = *bp2++;
- dith = (dmp[(x_align + x + 1) & (DM_WIDTH - 1)] << 2) | 3;
- pix1 = colorcube_d[(((r + dith) & 0x100) >> 2) |
- (((g + dith) & 0x100) >> 5) |
- (((b + dith) & 0x100) >> 8)];
+ pix1 = (g + ((b + r) >> 1)) >> shift;
+ obptr[0] = (pix0 << 4) | pix1;
+ obptr++;
+ }
+ bptr += rowstride;
+ obuf += bpl;
+ }
+}
+
+/* This actually works for depths from 3 to 7 */
+static void
+gdk_rgb_convert_gray4_d (GdkImage *image,
+ gint x0, gint y0, gint width, gint height,
+ guchar *buf, int rowstride,
+ gint x_align, gint y_align, GdkRgbCmap *cmap)
+{
+ int x, y;
+ gint bpl;
+ guchar *obuf, *obptr;
+ guchar *bptr, *bp2;
+ gint r, g, b;
+ guchar *dmp;
+ gint prec, right;
+ gint gray;
+
+ bptr = buf;
+ bpl = image->bpl;
+ obuf = ((guchar *)image->mem) + y0 * bpl + x0;
+ prec = image_info->visual->depth;
+ right = 8 - prec;
+ for (y = 0; y < height; y++)
+ {
+ bp2 = bptr;
+ obptr = obuf;
+ dmp = DM[(y_align + y) & (DM_HEIGHT - 1)];
+ for (x = 0; x < width; x++)
+ {
+ r = *bp2++;
+ g = *bp2++;
+ b = *bp2++;
+ gray = (g + ((b + r) >> 1)) >> 1;
+ gray += (dmp[(x_align + x) & (DM_WIDTH - 1)] << 2) >> prec;
+ obptr[0] = (gray - (gray >> prec)) >> right;
+ obptr++;
+ }
+ bptr += rowstride;
+ obuf += bpl;
+ }
+}
+
+static void
+gdk_rgb_convert_gray4_d_pack (GdkImage *image,
+ gint x0, gint y0, gint width, gint height,
+ guchar *buf, int rowstride,
+ gint x_align, gint y_align, GdkRgbCmap *cmap)
+{
+ int x, y;
+ gint bpl;
+ guchar *obuf, *obptr;
+ guchar *bptr, *bp2;
+ gint r, g, b;
+ guchar *dmp;
+ gint prec, right;
+ gint gray;
+ guchar pix0, pix1;
+ /* todo: this is hardcoded to big-endian. Make endian-agile. */
+
+ bptr = buf;
+ bpl = image->bpl;
+ obuf = ((guchar *)image->mem) + y0 * bpl + (x0 >> 1);
+ prec = image_info->visual->depth;
+ right = 8 - prec;
+ for (y = 0; y < height; y++)
+ {
+ bp2 = bptr;
+ obptr = obuf;
+ dmp = DM[(y_align + y) & (DM_HEIGHT - 1)];
+ for (x = 0; x < width; x += 2)
+ {
+ r = *bp2++;
+ g = *bp2++;
+ b = *bp2++;
+ gray = (g + ((b + r) >> 1)) >> 1;
+ gray += (dmp[(x_align + x) & (DM_WIDTH - 1)] << 2) >> prec;
+ pix0 = (gray - (gray >> prec)) >> right;
+ r = *bp2++;
+ g = *bp2++;
+ b = *bp2++;
+ gray = (g + ((b + r) >> 1)) >> 1;
+ gray += (dmp[(x_align + x + 1) & (DM_WIDTH - 1)] << 2) >> prec;
+ pix1 = (gray - (gray >> prec)) >> right;
obptr[0] = (pix0 << 4) | pix1;
obptr++;
}
-#endif
bptr += rowstride;
obuf += bpl;
}
}
+static void
+gdk_rgb_convert_1 (GdkImage *image,
+ gint x0, gint y0, gint width, gint height,
+ guchar *buf, int rowstride,
+ gint x_align, gint y_align,
+ GdkRgbCmap *cmap)
+{
+ int x, y;
+ gint bpl;
+ guchar *obuf, *obptr;
+ guchar *bptr, *bp2;
+ gint r, g, b;
+ guchar *dmp;
+ gint dith;
+ guchar byte;
+
+ bptr = buf;
+ bpl = image->bpl;
+ obuf = ((guchar *)image->mem) + y0 * bpl + (x0 >> 3);
+ byte = 0; /* unnecessary, but it keeps gcc from complaining */
+ for (y = 0; y < height; y++)
+ {
+ dmp = DM[(y_align + y) & (DM_HEIGHT - 1)];
+ bp2 = bptr;
+ obptr = obuf;
+ for (x = 0; x < width; x++)
+ {
+ r = *bp2++;
+ g = *bp2++;
+ b = *bp2++;
+ dith = (dmp[(x_align + x) & (DM_WIDTH - 1)] << 4) | 4;
+ byte += byte + (r + g + g + b + dith > 1020);
+ if ((x & 7) == 7)
+ {
+ obptr[0] = byte;
+ obptr++;
+ }
+ }
+ if (x & 7)
+ obptr[0] = byte << (8 - (x & 7));
+ bptr += rowstride;
+ obuf += bpl;
+ }
+}
/* Returns a pointer to the stage buffer. */
static guchar *
@@ -2386,11 +2621,16 @@ gdk_rgb_select_conv (GdkImage *image)
GdkRgbConvFunc conv_32, conv_32_d;
GdkRgbConvFunc conv_gray, conv_gray_d;
GdkRgbConvFunc conv_indexed, conv_indexed_d;
+ gboolean mask_rgb, mask_bgr;
depth = image_info->visual->depth;
- bpp = image->bpp;
+ bpp = ((GdkImagePrivate *)image)->ximage->bits_per_pixel;
byte_order = image->byte_order;
+ if (gdk_rgb_verbose)
+ g_print ("Chose visual 0x%x, image bpp=%d, %s first\n",
+ (gint)(((GdkVisualPrivate *)image_info->visual)->xvisual->visualid),
+ bpp, byte_order == GDK_LSB_FIRST ? "lsb" : "msb");
#ifdef WORDS_BIGENDIAN
byterev = (byte_order == GDK_LSB_FIRST);
@@ -2406,6 +2646,9 @@ gdk_rgb_select_conv (GdkImage *image)
green_mask = image_info->visual->green_mask;
blue_mask = image_info->visual->blue_mask;
+ mask_rgb = red_mask == 0xff0000 && green_mask == 0xff00 && blue_mask == 0xff;
+ mask_bgr = red_mask == 0xff && green_mask == 0xff00 && blue_mask == 0xff0000;
+
conv = NULL;
conv_d = NULL;
@@ -2420,7 +2663,9 @@ gdk_rgb_select_conv (GdkImage *image)
image_info->dith_default = FALSE;
- if (bpp == 2 && depth == 16 && !byterev &&
+ if (image_info->bitmap)
+ conv = gdk_rgb_convert_1;
+ else if (bpp == 16 && depth == 16 && !byterev &&
red_mask == 0xf800 && green_mask == 0x7e0 && blue_mask == 0x1f)
{
conv = gdk_rgb_convert_565;
@@ -2428,38 +2673,51 @@ gdk_rgb_select_conv (GdkImage *image)
conv_gray = gdk_rgb_convert_565_gray;
gdk_rgb_preprocess_dm_565 ();
}
- else if (bpp == 2 && depth == 16 &&
+ else if (bpp == 16 && depth == 16 &&
vtype == GDK_VISUAL_TRUE_COLOR && byterev &&
red_mask == 0xf800 && green_mask == 0x7e0 && blue_mask == 0x1f)
conv = gdk_rgb_convert_565_br;
- else if (bpp == 2 && depth == 15 &&
+ else if (bpp == 16 && depth == 15 &&
vtype == GDK_VISUAL_TRUE_COLOR && !byterev &&
red_mask == 0x7c00 && green_mask == 0x3e0 && blue_mask == 0x1f)
conv = gdk_rgb_convert_555;
- else if (bpp == 2 && depth == 15 &&
+ else if (bpp == 16 && depth == 15 &&
vtype == GDK_VISUAL_TRUE_COLOR && byterev &&
red_mask == 0x7c00 && green_mask == 0x3e0 && blue_mask == 0x1f)
conv = gdk_rgb_convert_555_br;
- /* I'm not 100% sure about the 24bpp tests */
- else if (bpp == 3 && depth == 24 &&
- vtype == GDK_VISUAL_TRUE_COLOR && byte_order == GDK_LSB_FIRST &&
- red_mask == 0xff0000 && green_mask == 0xff00 && blue_mask == 0xff)
+ /* I'm not 100% sure about the 24bpp tests - but testing will show*/
+ else if (bpp == 24 && depth == 24 && vtype == GDK_VISUAL_TRUE_COLOR &&
+ ((mask_rgb && byte_order == GDK_LSB_FIRST) ||
+ (mask_bgr && byte_order == GDK_MSB_FIRST)))
conv = gdk_rgb_convert_888_lsb;
- else if (bpp == 3 && depth == 24 &&
- vtype == GDK_VISUAL_TRUE_COLOR && byte_order == GDK_MSB_FIRST &&
- red_mask == 0xff0000 && green_mask == 0xff00 && blue_mask == 0xff)
+ else if (bpp == 24 && depth == 24 && vtype == GDK_VISUAL_TRUE_COLOR &&
+ ((mask_rgb && byte_order == GDK_MSB_FIRST) ||
+ (mask_bgr && byte_order == GDK_LSB_FIRST)))
conv = gdk_rgb_convert_888_msb;
- else if (bpp == 4 && depth == 24 &&
- vtype == GDK_VISUAL_TRUE_COLOR && !byterev &&
- red_mask == 0xff0000 && green_mask == 0xff00 && blue_mask == 0xff)
+#ifdef WORDS_BIGENDIAN
+ else if (bpp == 32 && depth == 24 && vtype == GDK_VISUAL_TRUE_COLOR &&
+ (mask_rgb && byte_order == GDK_LSB_FIRST))
+ conv = gdk_rgb_convert_0888_br;
+ else if (bpp == 32 && depth == 24 && vtype == GDK_VISUAL_TRUE_COLOR &&
+ (mask_rgb && byte_order == GDK_MSB_FIRST))
conv = gdk_rgb_convert_0888;
- else if (bpp == 4 && depth == 24 &&
- vtype == GDK_VISUAL_TRUE_COLOR && byterev &&
- red_mask == 0xff0000 && green_mask == 0xff00 && blue_mask == 0xff)
+ else if (bpp == 32 && depth == 24 && vtype == GDK_VISUAL_TRUE_COLOR &&
+ (mask_bgr && byte_order == GDK_MSB_FIRST))
+ conv = gdk_rgb_convert_8880_br;
+#else
+ else if (bpp == 32 && depth == 24 && vtype == GDK_VISUAL_TRUE_COLOR &&
+ (mask_rgb && byte_order == GDK_MSB_FIRST))
conv = gdk_rgb_convert_0888_br;
+ else if (bpp == 32 && depth == 24 && vtype == GDK_VISUAL_TRUE_COLOR &&
+ (mask_rgb && byte_order == GDK_LSB_FIRST))
+ conv = gdk_rgb_convert_0888;
+ else if (bpp == 32 && depth == 24 && vtype == GDK_VISUAL_TRUE_COLOR &&
+ (mask_bgr && byte_order == GDK_LSB_FIRST))
+ conv = gdk_rgb_convert_8880_br;
+#endif
else if (vtype == GDK_VISUAL_TRUE_COLOR && byte_order == GDK_LSB_FIRST)
{
@@ -2471,7 +2729,7 @@ gdk_rgb_select_conv (GdkImage *image)
conv = gdk_rgb_convert_truecolor_msb;
conv_d = gdk_rgb_convert_truecolor_msb_d;
}
- else if (bpp == 1 && depth == 8 && (vtype == GDK_VISUAL_PSEUDO_COLOR
+ else if (bpp == 8 && depth == 8 && (vtype == GDK_VISUAL_PSEUDO_COLOR
#ifdef ENABLE_GRAYSCALE
|| vtype == GDK_VISUAL_GRAYSCALE
#endif
@@ -2491,7 +2749,7 @@ gdk_rgb_select_conv (GdkImage *image)
conv_indexed = gdk_rgb_convert_8_indexed;
conv_gray = gdk_rgb_convert_gray_cmap;
}
- else if (bpp == 1 && depth == 8 && (vtype == GDK_VISUAL_STATIC_GRAY
+ else if (bpp == 8 && depth == 8 && (vtype == GDK_VISUAL_STATIC_GRAY
#ifdef not_ENABLE_GRAYSCALE
|| vtype == GDK_VISUAL_GRAYSCALE
#endif
@@ -2500,10 +2758,24 @@ gdk_rgb_select_conv (GdkImage *image)
conv = gdk_rgb_convert_gray8;
conv_gray = gdk_rgb_convert_gray8_gray;
}
- else if (depth == 4)
+ else if (bpp == 8 && depth < 8 && depth >= 2 &&
+ (vtype == GDK_VISUAL_STATIC_GRAY
+ || vtype == GDK_VISUAL_GRAYSCALE))
+ {
+ conv = gdk_rgb_convert_gray4;
+ conv_d = gdk_rgb_convert_gray4_d;
+ }
+ else if (bpp == 8 && depth < 8 && depth >= 3)
{
conv = gdk_rgb_convert_4;
}
+ else if (bpp == 4 && depth <= 4 && depth >= 2 &&
+ (vtype == GDK_VISUAL_STATIC_GRAY
+ || vtype == GDK_VISUAL_GRAYSCALE))
+ {
+ conv = gdk_rgb_convert_gray4_pack;
+ conv_d = gdk_rgb_convert_gray4_d_pack;
+ }
if (conv_d == NULL)
conv_d = conv;
@@ -2566,7 +2838,6 @@ gdk_rgb_alloc_scratch (gint width, gint height, gint *x0, gint *y0)
GdkImage *image;
gint idx;
-
if (width >= (IMAGE_WIDTH >> 1))
{
if (height >= (IMAGE_HEIGHT >> 1))
@@ -2600,7 +2871,9 @@ gdk_rgb_alloc_scratch (gint width, gint height, gint *x0, gint *y0)
idx = vert_idx;
*x0 = vert_x;
*y0 = 0;
- vert_x += (width + 3) & -4;
+ /* using 3 and -4 would be slightly more efficient on 32-bit machines
+ with > 1bpp displays */
+ vert_x += (width + 7) & -8;
}
else
{
@@ -2621,7 +2894,7 @@ gdk_rgb_alloc_scratch (gint width, gint height, gint *x0, gint *y0)
idx = tile_idx;
*x0 = tile_x;
*y0 = tile_y1;
- tile_x += (width + 3) & -4;
+ tile_x += (width + 7) & -8;
}
}
image = static_image[idx];
@@ -2643,7 +2916,9 @@ gdk_draw_rgb_image_core (GdkDrawable *drawable,
gint pixstride,
gint rowstride,
GdkRgbConvFunc conv,
- GdkRgbCmap *cmap)
+ GdkRgbCmap *cmap,
+ gint xdith,
+ gint ydith)
{
gint y0, x0;
gint xs0, ys0;
@@ -2651,6 +2926,20 @@ gdk_draw_rgb_image_core (GdkDrawable *drawable,
gint width1, height1;
guchar *buf_ptr;
+ if (image_info->bitmap)
+ {
+ if (image_info->own_gc == NULL)
+ {
+ GdkColor color;
+
+ image_info->own_gc = gdk_gc_new (drawable);
+ gdk_color_white (image_info->cmap, &color);
+ gdk_gc_set_foreground (image_info->own_gc, &color);
+ gdk_color_black (image_info->cmap, &color);
+ gdk_gc_set_background (image_info->own_gc, &color);
+ }
+ gc = image_info->own_gc;
+ }
for (y0 = 0; y0 < height; y0 += IMAGE_HEIGHT)
{
height1 = MIN (height - y0, IMAGE_HEIGHT);
@@ -2662,7 +2951,7 @@ gdk_draw_rgb_image_core (GdkDrawable *drawable,
image = gdk_rgb_alloc_scratch (width1, height1, &xs0, &ys0);
conv (image, xs0, ys0, width1, height1, buf_ptr, rowstride,
- x + x0, y + y0, cmap);
+ x + x0 + xdith, y + y0 + ydith, cmap);
#ifndef DONT_ACTUALLY_DRAW
gdk_draw_image (drawable, gc,
@@ -2687,10 +2976,36 @@ gdk_draw_rgb_image (GdkDrawable *drawable,
if (dith == GDK_RGB_DITHER_NONE || (dith == GDK_RGB_DITHER_NORMAL &&
!image_info->dith_default))
gdk_draw_rgb_image_core (drawable, gc, x, y, width, height,
- rgb_buf, 3, rowstride, image_info->conv, NULL);
+ rgb_buf, 3, rowstride, image_info->conv, NULL,
+ 0, 0);
+ else
+ gdk_draw_rgb_image_core (drawable, gc, x, y, width, height,
+ rgb_buf, 3, rowstride, image_info->conv_d, NULL,
+ 0, 0);
+}
+
+void
+gdk_draw_rgb_image_dithalign (GdkDrawable *drawable,
+ GdkGC *gc,
+ gint x,
+ gint y,
+ gint width,
+ gint height,
+ GdkRgbDither dith,
+ guchar *rgb_buf,
+ gint rowstride,
+ gint xdith,
+ gint ydith)
+{
+ if (dith == GDK_RGB_DITHER_NONE || (dith == GDK_RGB_DITHER_NORMAL &&
+ !image_info->dith_default))
+ gdk_draw_rgb_image_core (drawable, gc, x, y, width, height,
+ rgb_buf, 3, rowstride, image_info->conv, NULL,
+ xdith, ydith);
else
gdk_draw_rgb_image_core (drawable, gc, x, y, width, height,
- rgb_buf, 3, rowstride, image_info->conv_d, NULL);
+ rgb_buf, 3, rowstride, image_info->conv_d, NULL,
+ xdith, ydith);
}
void
@@ -2708,11 +3023,11 @@ gdk_draw_rgb_32_image (GdkDrawable *drawable,
!image_info->dith_default))
gdk_draw_rgb_image_core (drawable, gc, x, y, width, height,
buf, 4, rowstride,
- image_info->conv_32, NULL);
+ image_info->conv_32, NULL, 0, 0);
else
gdk_draw_rgb_image_core (drawable, gc, x, y, width, height,
buf, 4, rowstride,
- image_info->conv_32_d, NULL);
+ image_info->conv_32_d, NULL, 0, 0);
}
static void
@@ -2747,11 +3062,11 @@ gdk_draw_gray_image (GdkDrawable *drawable,
!image_info->dith_default))
gdk_draw_rgb_image_core (drawable, gc, x, y, width, height,
buf, 1, rowstride,
- image_info->conv_gray, NULL);
+ image_info->conv_gray, NULL, 0, 0);
else
gdk_draw_rgb_image_core (drawable, gc, x, y, width, height,
buf, 1, rowstride,
- image_info->conv_gray_d, NULL);
+ image_info->conv_gray_d, NULL, 0, 0);
}
GdkRgbCmap *
@@ -2804,11 +3119,11 @@ gdk_draw_indexed_image (GdkDrawable *drawable,
!image_info->dith_default))
gdk_draw_rgb_image_core (drawable, gc, x, y, width, height,
buf, 1, rowstride,
- image_info->conv_indexed, cmap);
+ image_info->conv_indexed, cmap, 0, 0);
else
gdk_draw_rgb_image_core (drawable, gc, x, y, width, height,
buf, 1, rowstride,
- image_info->conv_indexed_d, cmap);
+ image_info->conv_indexed_d, cmap, 0, 0);
}
gboolean
diff --git a/gdk/gdkrgb.h b/gdk/gdkrgb.h
index 4b12a32698..ee6f74ad4d 100644
--- a/gdk/gdkrgb.h
+++ b/gdk/gdkrgb.h
@@ -61,6 +61,19 @@ gdk_draw_rgb_image (GdkDrawable *drawable,
gint rowstride);
void
+gdk_draw_rgb_image_dithalign (GdkDrawable *drawable,
+ GdkGC *gc,
+ gint x,
+ gint y,
+ gint width,
+ gint height,
+ GdkRgbDither dith,
+ guchar *rgb_buf,
+ gint rowstride,
+ gint xdith,
+ gint ydith);
+
+void
gdk_draw_rgb_32_image (GdkDrawable *drawable,
GdkGC *gc,
gint x,
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 275ca3aa98..0655f3c198 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -2579,4 +2579,3 @@ gdk_drawable_set_data (GdkDrawable *drawable,
{
g_dataset_set_data_full (drawable, key, data, destroy_func);
}
-
diff --git a/gdk/x11/gdkcolor-x11.c b/gdk/x11/gdkcolor-x11.c
index fa810473e6..36b6c8593c 100644
--- a/gdk/x11/gdkcolor-x11.c
+++ b/gdk/x11/gdkcolor-x11.c
@@ -71,8 +71,8 @@ gdk_colormap_new (GdkVisual *visual,
private->info = g_new0 (GdkColorInfo, colormap->size);
colormap->colors = g_new (GdkColor, colormap->size);
- private->hash = g_hash_table_new (gdk_color_hash,
- gdk_color_equal);
+ private->hash = g_hash_table_new ((GHashFunc) gdk_color_hash,
+ (GCompareFunc) gdk_color_equal);
private->private_val = private_cmap;
private->xcolormap = XCreateColormap (private->xdisplay, gdk_root_window,
@@ -259,8 +259,8 @@ gdk_colormap_get_system (void)
private->info = g_new0 (GdkColorInfo, colormap->size);
colormap->colors = g_new (GdkColor, colormap->size);
- private->hash = g_hash_table_new (gdk_color_hash,
- gdk_color_equal);
+ private->hash = g_hash_table_new ((GHashFunc) gdk_color_hash,
+ (GCompareFunc) gdk_color_equal);
gdk_colormap_sync (colormap, TRUE);
}
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index 275ca3aa98..0655f3c198 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -2579,4 +2579,3 @@ gdk_drawable_set_data (GdkDrawable *drawable,
{
g_dataset_set_data_full (drawable, key, data, destroy_func);
}
-