Minor fixes that were needed for the Gimp/GdkRgb integration.

This commit is contained in:
Raph Levien 1998-08-20 06:52:52 +00:00
parent 38db8d1951
commit f1a524a21e
10 changed files with 564 additions and 1511 deletions

View File

@ -1,3 +1,16 @@
1998-08-19 Raph Levien <raph@gimp.org>
* gdk/gdkrgb.c: fixed some bugs in the 565_d mode, and added a
4bpp static_color mode (for vga displays). Also fixed a '64' value
in the dither matrix, which was causing one pixel out of 16k to be
dithered wrong.
* gtk/gtkpreview.{c,h}: Changed it to work with GdkRgb, gutting
most of the contents. This is an API change - any apps that relied
on the internal structure of GtkPreview will need some change -
most notably in the use of reserved colors. The Gimp needed
changes in this regard.
Wed Aug 19 00:11:14 1998 Tim Janik <timj@gtk.org> Wed Aug 19 00:11:14 1998 Tim Janik <timj@gtk.org>
* gtk/gtkmain.c (gtk_init): allow argument parsing in gtk without * gtk/gtkmain.c (gtk_init): allow argument parsing in gtk without

View File

@ -1,3 +1,16 @@
1998-08-19 Raph Levien <raph@gimp.org>
* gdk/gdkrgb.c: fixed some bugs in the 565_d mode, and added a
4bpp static_color mode (for vga displays). Also fixed a '64' value
in the dither matrix, which was causing one pixel out of 16k to be
dithered wrong.
* gtk/gtkpreview.{c,h}: Changed it to work with GdkRgb, gutting
most of the contents. This is an API change - any apps that relied
on the internal structure of GtkPreview will need some change -
most notably in the use of reserved colors. The Gimp needed
changes in this regard.
Wed Aug 19 00:11:14 1998 Tim Janik <timj@gtk.org> Wed Aug 19 00:11:14 1998 Tim Janik <timj@gtk.org>
* gtk/gtkmain.c (gtk_init): allow argument parsing in gtk without * gtk/gtkmain.c (gtk_init): allow argument parsing in gtk without

View File

@ -1,3 +1,16 @@
1998-08-19 Raph Levien <raph@gimp.org>
* gdk/gdkrgb.c: fixed some bugs in the 565_d mode, and added a
4bpp static_color mode (for vga displays). Also fixed a '64' value
in the dither matrix, which was causing one pixel out of 16k to be
dithered wrong.
* gtk/gtkpreview.{c,h}: Changed it to work with GdkRgb, gutting
most of the contents. This is an API change - any apps that relied
on the internal structure of GtkPreview will need some change -
most notably in the use of reserved colors. The Gimp needed
changes in this regard.
Wed Aug 19 00:11:14 1998 Tim Janik <timj@gtk.org> Wed Aug 19 00:11:14 1998 Tim Janik <timj@gtk.org>
* gtk/gtkmain.c (gtk_init): allow argument parsing in gtk without * gtk/gtkmain.c (gtk_init): allow argument parsing in gtk without

View File

@ -1,3 +1,16 @@
1998-08-19 Raph Levien <raph@gimp.org>
* gdk/gdkrgb.c: fixed some bugs in the 565_d mode, and added a
4bpp static_color mode (for vga displays). Also fixed a '64' value
in the dither matrix, which was causing one pixel out of 16k to be
dithered wrong.
* gtk/gtkpreview.{c,h}: Changed it to work with GdkRgb, gutting
most of the contents. This is an API change - any apps that relied
on the internal structure of GtkPreview will need some change -
most notably in the use of reserved colors. The Gimp needed
changes in this regard.
Wed Aug 19 00:11:14 1998 Tim Janik <timj@gtk.org> Wed Aug 19 00:11:14 1998 Tim Janik <timj@gtk.org>
* gtk/gtkmain.c (gtk_init): allow argument parsing in gtk without * gtk/gtkmain.c (gtk_init): allow argument parsing in gtk without

View File

@ -1,3 +1,16 @@
1998-08-19 Raph Levien <raph@gimp.org>
* gdk/gdkrgb.c: fixed some bugs in the 565_d mode, and added a
4bpp static_color mode (for vga displays). Also fixed a '64' value
in the dither matrix, which was causing one pixel out of 16k to be
dithered wrong.
* gtk/gtkpreview.{c,h}: Changed it to work with GdkRgb, gutting
most of the contents. This is an API change - any apps that relied
on the internal structure of GtkPreview will need some change -
most notably in the use of reserved colors. The Gimp needed
changes in this regard.
Wed Aug 19 00:11:14 1998 Tim Janik <timj@gtk.org> Wed Aug 19 00:11:14 1998 Tim Janik <timj@gtk.org>
* gtk/gtkmain.c (gtk_init): allow argument parsing in gtk without * gtk/gtkmain.c (gtk_init): allow argument parsing in gtk without

View File

@ -1,3 +1,16 @@
1998-08-19 Raph Levien <raph@gimp.org>
* gdk/gdkrgb.c: fixed some bugs in the 565_d mode, and added a
4bpp static_color mode (for vga displays). Also fixed a '64' value
in the dither matrix, which was causing one pixel out of 16k to be
dithered wrong.
* gtk/gtkpreview.{c,h}: Changed it to work with GdkRgb, gutting
most of the contents. This is an API change - any apps that relied
on the internal structure of GtkPreview will need some change -
most notably in the use of reserved colors. The Gimp needed
changes in this regard.
Wed Aug 19 00:11:14 1998 Tim Janik <timj@gtk.org> Wed Aug 19 00:11:14 1998 Tim Janik <timj@gtk.org>
* gtk/gtkmain.c (gtk_init): allow argument parsing in gtk without * gtk/gtkmain.c (gtk_init): allow argument parsing in gtk without

View File

@ -1,3 +1,16 @@
1998-08-19 Raph Levien <raph@gimp.org>
* gdk/gdkrgb.c: fixed some bugs in the 565_d mode, and added a
4bpp static_color mode (for vga displays). Also fixed a '64' value
in the dither matrix, which was causing one pixel out of 16k to be
dithered wrong.
* gtk/gtkpreview.{c,h}: Changed it to work with GdkRgb, gutting
most of the contents. This is an API change - any apps that relied
on the internal structure of GtkPreview will need some change -
most notably in the use of reserved colors. The Gimp needed
changes in this regard.
Wed Aug 19 00:11:14 1998 Tim Janik <timj@gtk.org> Wed Aug 19 00:11:14 1998 Tim Janik <timj@gtk.org>
* gtk/gtkmain.c (gtk_init): allow argument parsing in gtk without * gtk/gtkmain.c (gtk_init): allow argument parsing in gtk without

View File

@ -20,7 +20,7 @@
/* For more information on GdkRgb, see http://www.levien.com/gdkrgb/ /* For more information on GdkRgb, see http://www.levien.com/gdkrgb/
Raph Levien <raph@acm.org> Raph Levien <raph@acm.org>
*/ */
#include <math.h> #include <math.h>
#include <stdio.h> #include <stdio.h>
@ -125,7 +125,7 @@ gdk_rgb_cmap_fail (const char *msg, GdkColormap *cmap, gulong *pixels)
gint i; gint i;
#ifdef VERBOSE #ifdef VERBOSE
g_message ("%s", msg); g_print ("%s", msg);
#endif #endif
n_free = 0; n_free = 0;
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
@ -154,7 +154,7 @@ gdk_rgb_make_colorcube (gulong *pixels, gint nr, gint ng, gint nb)
{ {
colorcube[i] = pixels[rt[i >> 8] + gt[(i >> 4) & 0x0f] + bt[i & 0x0f]]; colorcube[i] = pixels[rt[i >> 8] + gt[(i >> 4) & 0x0f] + bt[i & 0x0f]];
#ifdef VERBOSE #ifdef VERBOSE
g_message ("%03x %02x %x %x %x", i, colorcube[i], rt[i >> 8], gt[(i >> 4) & 0x0f], bt[i & 0x0f]); g_print ("%03x %02x %x %x %x\n", i, colorcube[i], rt[i >> 8], gt[(i >> 4) & 0x0f], bt[i & 0x0f]);
#endif #endif
} }
} }
@ -211,33 +211,33 @@ gdk_rgb_try_colormap (gint nr, gint ng, gint nb)
#ifndef GAMMA #ifndef GAMMA
if (!gdk_rgb_install_cmap) if (!gdk_rgb_install_cmap)
/* find color cube colors that are already present */ /* find color cube colors that are already present */
for (i = 0; i < MIN (256, cmap->size); i++) for (i = 0; i < MIN (256, cmap->size); i++)
{ {
r = cmap->colors[i].red >> 8; r = cmap->colors[i].red >> 8;
g = cmap->colors[i].green >> 8; g = cmap->colors[i].green >> 8;
b = cmap->colors[i].blue >> 8; b = cmap->colors[i].blue >> 8;
ri = (r * (nr - 1) + 128) >> 8; ri = (r * (nr - 1) + 128) >> 8;
gi = (g * (ng - 1) + 128) >> 8; gi = (g * (ng - 1) + 128) >> 8;
bi = (b * (nb - 1) + 128) >> 8; bi = (b * (nb - 1) + 128) >> 8;
r0 = ri * 255 / (nr - 1); r0 = ri * 255 / (nr - 1);
g0 = gi * 255 / (ng - 1); g0 = gi * 255 / (ng - 1);
b0 = bi * 255 / (nb - 1); b0 = bi * 255 / (nb - 1);
idx = ((ri * nr) + gi) * nb + bi; idx = ((ri * nr) + gi) * nb + bi;
d2 = (r - r0) * (r - r0) + (g - g0) * (g - g0) + (b - b0) * (b - b0); d2 = (r - r0) * (r - r0) + (g - g0) * (g - g0) + (b - b0) * (b - b0);
if (d2 < best[idx]) { if (d2 < best[idx]) {
if (pixels[idx] < 256) if (pixels[idx] < 256)
gdk_colors_free (cmap, pixels + idx, 1, 0); gdk_colors_free (cmap, pixels + idx, 1, 0);
else else
colors_needed--; colors_needed--;
color = cmap->colors[i]; color = cmap->colors[i];
if (!gdk_color_alloc (cmap, &color)) if (!gdk_color_alloc (cmap, &color))
return gdk_rgb_cmap_fail ("error allocating system color", return gdk_rgb_cmap_fail ("error allocating system color\n",
cmap, pixels); cmap, pixels);
pixels[idx] = color.pixel; /* which is almost certainly i */ pixels[idx] = color.pixel; /* which is almost certainly i */
best[idx] = d2; best[idx] = d2;
}
} }
}
#endif #endif
if (colors_needed) if (colors_needed)
@ -247,7 +247,7 @@ gdk_rgb_try_colormap (gint nr, gint ng, gint nb)
char tmp_str[80]; char tmp_str[80];
sprintf (tmp_str, sprintf (tmp_str,
"%d %d %d colormap failed (in gdk_colors_alloc)", "%d %d %d colormap failed (in gdk_colors_alloc)\n",
nr, ng, nb); nr, ng, nb);
return gdk_rgb_cmap_fail (tmp_str, cmap, pixels); return gdk_rgb_cmap_fail (tmp_str, cmap, pixels);
} }
@ -271,11 +271,12 @@ gdk_rgb_try_colormap (gint nr, gint ng, gint nb)
color.blue = 65535 * pow (color.blue / 65535.0, 0.5); color.blue = 65535 * pow (color.blue / 65535.0, 0.5);
#endif #endif
/* This should be a raw XAllocColor call */
if (!gdk_color_alloc (cmap, &color)) if (!gdk_color_alloc (cmap, &color))
{ {
char tmp_str[80]; char tmp_str[80];
sprintf (tmp_str, "%d %d %d colormap failed", sprintf (tmp_str, "%d %d %d colormap failed\n",
nr, ng, nb); nr, ng, nb);
return gdk_rgb_cmap_fail (tmp_str, return gdk_rgb_cmap_fail (tmp_str,
cmap, pixels); cmap, pixels);
@ -283,7 +284,7 @@ gdk_rgb_try_colormap (gint nr, gint ng, gint nb)
pixels[i] = color.pixel; pixels[i] = color.pixel;
} }
#ifdef VERBOSE #ifdef VERBOSE
g_message ("%d: %lx", i, pixels[i]); g_print ("%d: %lx\n", i, pixels[i]);
#endif #endif
} }
@ -300,7 +301,7 @@ static gboolean
gdk_rgb_do_colormaps (void) gdk_rgb_do_colormaps (void)
{ {
const gint sizes[][3] = { const gint sizes[][3] = {
/* { 6, 7, 6 }, */ /* { 6, 7, 6 }, */
{ 6, 6, 6 }, { 6, 6, 6 },
{ 6, 6, 5 }, { 6, 6, 5 },
{ 6, 6, 4 }, { 6, 6, 4 },
@ -320,6 +321,31 @@ gdk_rgb_do_colormaps (void)
return FALSE; return FALSE;
} }
/* Make a 2 x 2 x 2 colorcube */
static void
gdk_rgb_colorcube_222 (void)
{
int i;
GdkColor color;
GdkColormap *cmap;
if (image_info->cmap_alloced)
cmap = image_info->cmap;
else
cmap = gdk_colormap_get_system ();
colorcube_d = g_new (guchar, 512);
for (i = 0; i < 8; i++)
{
color.red = ((i & 4) >> 2) * 65535;
color.green = ((i & 2) >> 1) * 65535;
color.blue = (i & 1) * 65535;
gdk_color_alloc (cmap, &color);
colorcube_d[((i & 4) << 4) | ((i & 2) << 2) | (i & 1)] = color.pixel;
}
}
void void
gdk_rgb_set_verbose (gboolean verbose) gdk_rgb_set_verbose (gboolean verbose)
{ {
@ -341,11 +367,11 @@ gdk_rgb_set_min_colors (gint min_colors)
/* Return a "score" based on the following criteria (in hex): /* Return a "score" based on the following criteria (in hex):
x000 is the quality - 1 is 1bpp, 2 is 4bpp, x000 is the quality - 1 is 1bpp, 2 is 4bpp,
4 is 8bpp, 4 is 8bpp,
7 is 15bpp truecolor, 8 is 16bpp truecolor, 7 is 15bpp truecolor, 8 is 16bpp truecolor,
9 is 24bpp truecolor. 9 is 24bpp truecolor.
0x00 is the speed - 1 is the normal case, 0x00 is the speed - 1 is the normal case,
2 means faster than normal 2 means faster than normal
00x0 gets a point for being the system visual 00x0 gets a point for being the system visual
000x gets a point for being pseudocolor 000x gets a point for being pseudocolor
@ -386,10 +412,15 @@ gdk_rgb_score_visual (GdkVisual *visual)
else if (visual->depth == 8) else if (visual->depth == 8)
quality = 4; quality = 4;
} }
else if (visual->type == GDK_VISUAL_PSEUDO_COLOR) else if (visual->type == GDK_VISUAL_PSEUDO_COLOR ||
visual->type == GDK_VISUAL_STATIC_COLOR)
{ {
if (visual->depth == 8) if (visual->depth == 8)
quality = 4; quality = 4;
else if (visual->depth == 4)
quality = 2;
else if (visual->depth == 1)
quality = 1;
} }
else if (visual->type == GDK_VISUAL_STATIC_GRAY else if (visual->type == GDK_VISUAL_STATIC_GRAY
#ifdef ENABLE_GRAYSCALE #ifdef ENABLE_GRAYSCALE
@ -413,15 +444,15 @@ gdk_rgb_score_visual (GdkVisual *visual)
pseudo = (visual->type == GDK_VISUAL_PSEUDO_COLOR); pseudo = (visual->type == GDK_VISUAL_PSEUDO_COLOR);
if (gdk_rgb_verbose) if (gdk_rgb_verbose)
g_message ("Visual 0x%x, type = %s, depth = %d, %x:%x:%x%s; score=%x", g_print ("Visual 0x%x, type = %s, depth = %d, %x:%x:%x%s; score=%x\n",
(gint)(((GdkVisualPrivate *)visual)->xvisual->visualid), (gint)(((GdkVisualPrivate *)visual)->xvisual->visualid),
visual_names[visual->type], visual_names[visual->type],
visual->depth, visual->depth,
visual->red_mask, visual->red_mask,
visual->green_mask, visual->green_mask,
visual->blue_mask, visual->blue_mask,
sys ? " (system)" : "", sys ? " (system)" : "",
(quality << 12) | (speed << 8) | (sys << 4) | pseudo); (quality << 12) | (speed << 8) | (sys << 4) | pseudo);
return (quality << 12) | (speed << 8) | (sys << 4) | pseudo; return (quality << 12) | (speed << 8) | (sys << 4) | pseudo;
} }
@ -473,8 +504,8 @@ gdk_rgb_set_gray_cmap (GdkColormap *cmap)
status = gdk_color_alloc (cmap, &color); status = gdk_color_alloc (cmap, &color);
pixels[i] = color.pixel; pixels[i] = color.pixel;
#ifdef VERBOSE #ifdef VERBOSE
g_message ("allocating pixel %d, %x %x %x, result %d", g_print ("allocating pixel %d, %x %x %x, result %d\n",
color.pixel, color.red, color.green, color.blue, status); color.pixel, color.red, color.green, color.blue, status);
#endif #endif
} }
@ -536,7 +567,11 @@ gdk_rgb_init (void)
gdk_rgb_choose_visual (); gdk_rgb_choose_visual ();
if (image_info->visual->type == GDK_VISUAL_PSEUDO_COLOR) if (image_info->visual->depth == 4)
{
gdk_rgb_colorcube_222 ();
}
else if (image_info->visual->type == GDK_VISUAL_PSEUDO_COLOR)
{ {
if (gdk_rgb_install_cmap || if (gdk_rgb_install_cmap ||
image_info->visual != gdk_visual_get_system ()) image_info->visual != gdk_visual_get_system ())
@ -551,13 +586,13 @@ gdk_rgb_init (void)
gdk_rgb_do_colormaps (); gdk_rgb_do_colormaps ();
} }
if (gdk_rgb_verbose) if (gdk_rgb_verbose)
g_message ("color cube: %d x %d x %d", g_print ("color cube: %d x %d x %d\n",
image_info->nred_shades, image_info->nred_shades,
image_info->ngreen_shades, image_info->ngreen_shades,
image_info->nblue_shades); image_info->nblue_shades);
if (!image_info->cmap_alloced) if (!image_info->cmap_alloced)
image_info->cmap = gdk_colormap_get_system (); image_info->cmap = gdk_colormap_get_system ();
} }
#ifdef ENABLE_GRAYSCALE #ifdef ENABLE_GRAYSCALE
else if (image_info->visual->type == GDK_VISUAL_GRAYSCALE) else if (image_info->visual->type == GDK_VISUAL_GRAYSCALE)
@ -565,7 +600,7 @@ gdk_rgb_init (void)
image_info->cmap = gdk_colormap_new (image_info->visual, FALSE); image_info->cmap = gdk_colormap_new (image_info->visual, FALSE);
gdk_rgb_set_gray_cmap (image_info->cmap); gdk_rgb_set_gray_cmap (image_info->cmap);
image_info->cmap_alloced = TRUE; image_info->cmap_alloced = TRUE;
} }
#endif #endif
else else
{ {
@ -602,29 +637,34 @@ gdk_rgb_xpixel_from_rgb (guint32 rgb)
pixel = colorcube[((rgb & 0xf00000) >> 12) | pixel = colorcube[((rgb & 0xf00000) >> 12) |
((rgb & 0xf000) >> 8) | ((rgb & 0xf000) >> 8) |
((rgb & 0xf0) >> 4)]; ((rgb & 0xf0) >> 4)];
else if (image_info->visual->depth == 4 &&
image_info->visual->type == GDK_VISUAL_STATIC_COLOR)
{
pixel = colorcube_d[((rgb & 0x800000) >> 17) |
((rgb & 0x8000) >> 12) |
((rgb & 0x80) >> 7)];
}
else else
{ {
#ifdef VERBOSE #ifdef VERBOSE
g_message ("shift, prec: r %d %d g %d %d b %d %d", g_print ("shift, prec: r %d %d g %d %d b %d %d\n",
image_info->visual->red_shift, image_info->visual->red_shift,
image_info->visual->red_prec, image_info->visual->red_prec,
image_info->visual->green_shift, image_info->visual->green_shift,
image_info->visual->green_prec, image_info->visual->green_prec,
image_info->visual->blue_shift, image_info->visual->blue_shift,
image_info->visual->blue_prec); image_info->visual->blue_prec);
#endif #endif
pixel = (((((rgb & 0xff0000) >> 16) >> pixel = (((((rgb & 0xff0000) >> 16) >>
(8 - image_info->visual->red_prec)) << (8 - image_info->visual->red_prec)) <<
image_info->visual->red_shift) + image_info->visual->red_shift) +
((((rgb & 0xff00) >> 8) >> ((((rgb & 0xff00) >> 8) >>
(8 - image_info->visual->green_prec)) << (8 - image_info->visual->green_prec)) <<
image_info->visual->green_shift) + image_info->visual->green_shift) +
(((rgb & 0xff) >> (((rgb & 0xff) >>
(8 - image_info->visual->blue_prec)) << (8 - image_info->visual->blue_prec)) <<
image_info->visual->blue_shift)); image_info->visual->blue_shift));
;
} }
return pixel; return pixel;
@ -672,7 +712,7 @@ gdk_rgb_convert_8 (GdkImage *image,
{ {
bp2 = bptr; bp2 = bptr;
obptr = obuf; obptr = obuf;
if (width < 8 || (((unsigned long)obuf | (unsigned long) bp2) & 3)) if (((unsigned long)obuf | (unsigned long) bp2) & 3)
{ {
for (x = 0; x < width; x++) for (x = 0; x < width; x++)
{ {
@ -877,7 +917,7 @@ static guchar DM[128][128] =
{ 46, 2, 56, 11, 41, 1, 49, 6, 27, 47, 2, 48, 5, 32, 37, 3, 13, 19, 32, 1, 55, 28, 60, 17, 43, 59, 32, 20, 49, 16, 55, 23, 14, 46, 2, 36, 6, 30, 20, 49, 12, 47, 35, 14, 21, 60, 29, 14, 35, 24, 46, 1, 56, 29, 53, 8, 33, 23, 56, 1, 35, 46, 20, 39, 26, 4, 53, 28, 17, 38, 60, 34, 48, 9, 55, 15, 46, 7, 41, 31, 60, 24, 16, 36, 1, 59, 19, 52, 35, 6, 55, 11, 59, 33, 7, 57, 4, 29, 48, 1, 19, 26, 37, 30, 18, 63, 37, 6, 59, 1, 40, 24, 56, 33, 46, 22, 35, 7, 24, 53, 39, 5, 26, 45, 55, 18, 62, 7 }, { 46, 2, 56, 11, 41, 1, 49, 6, 27, 47, 2, 48, 5, 32, 37, 3, 13, 19, 32, 1, 55, 28, 60, 17, 43, 59, 32, 20, 49, 16, 55, 23, 14, 46, 2, 36, 6, 30, 20, 49, 12, 47, 35, 14, 21, 60, 29, 14, 35, 24, 46, 1, 56, 29, 53, 8, 33, 23, 56, 1, 35, 46, 20, 39, 26, 4, 53, 28, 17, 38, 60, 34, 48, 9, 55, 15, 46, 7, 41, 31, 60, 24, 16, 36, 1, 59, 19, 52, 35, 6, 55, 11, 59, 33, 7, 57, 4, 29, 48, 1, 19, 26, 37, 30, 18, 63, 37, 6, 59, 1, 40, 24, 56, 33, 46, 22, 35, 7, 24, 53, 39, 5, 26, 45, 55, 18, 62, 7 },
{ 20, 60, 29, 34, 20, 62, 33, 52, 10, 36, 13, 60, 41, 21, 50, 27, 56, 49, 8, 51, 21, 45, 11, 48, 8, 23, 53, 3, 29, 44, 5, 52, 9, 32, 50, 17, 43, 56, 3, 38, 24, 10, 62, 25, 51, 9, 33, 49, 61, 7, 30, 62, 22, 19, 2, 42, 63, 5, 49, 18, 60, 15, 52, 7, 43, 56, 23, 50, 5, 50, 2, 20, 41, 30, 1, 52, 22, 61, 14, 26, 3, 43, 53, 7, 47, 28, 11, 14, 23, 58, 33, 25, 47, 13, 50, 17, 40, 54, 34, 60, 41, 6, 59, 14, 50, 7, 25, 55, 20, 42, 51, 8, 27, 4, 16, 60, 28, 50, 44, 3, 22, 49, 63, 12, 33, 1, 43, 31 }, { 20, 60, 29, 34, 20, 62, 33, 52, 10, 36, 13, 60, 41, 21, 50, 27, 56, 49, 8, 51, 21, 45, 11, 48, 8, 23, 53, 3, 29, 44, 5, 52, 9, 32, 50, 17, 43, 56, 3, 38, 24, 10, 62, 25, 51, 9, 33, 49, 61, 7, 30, 62, 22, 19, 2, 42, 63, 5, 49, 18, 60, 15, 52, 7, 43, 56, 23, 50, 5, 50, 2, 20, 41, 30, 1, 52, 22, 61, 14, 26, 3, 43, 53, 7, 47, 28, 11, 14, 23, 58, 33, 25, 47, 13, 50, 17, 40, 54, 34, 60, 41, 6, 59, 14, 50, 7, 25, 55, 20, 42, 51, 8, 27, 4, 16, 60, 28, 50, 44, 3, 22, 49, 63, 12, 33, 1, 43, 31 },
{ 36, 5, 46, 8, 44, 24, 13, 39, 25, 57, 31, 18, 8, 52, 10, 45, 6, 30, 36, 24, 63, 4, 33, 26, 57, 40, 15, 56, 37, 12, 40, 25, 37, 58, 11, 63, 21, 45, 16, 60, 31, 53, 18, 33, 3, 45, 23, 0, 20, 54, 40, 15, 50, 38, 60, 16, 25, 42, 29, 38, 7, 41, 25, 62, 18, 33, 8, 35, 42, 16, 32, 56, 12, 39, 59, 19, 34, 9, 49, 38, 57, 12, 21, 50, 14, 40, 61, 44, 50, 9, 49, 19, 3, 29, 35, 62, 12, 24, 7, 18, 52, 32, 10, 46, 21, 41, 32, 11, 36, 29, 14, 34, 60, 38, 54, 11, 41, 14, 19, 57, 32, 16, 7, 41, 51, 25, 14, 57 }, { 36, 5, 46, 8, 44, 24, 13, 39, 25, 57, 31, 18, 8, 52, 10, 45, 6, 30, 36, 24, 63, 4, 33, 26, 57, 40, 15, 56, 37, 12, 40, 25, 37, 58, 11, 63, 21, 45, 16, 60, 31, 53, 18, 33, 3, 45, 23, 0, 20, 54, 40, 15, 50, 38, 60, 16, 25, 42, 29, 38, 7, 41, 25, 62, 18, 33, 8, 35, 42, 16, 32, 56, 12, 39, 59, 19, 34, 9, 49, 38, 57, 12, 21, 50, 14, 40, 61, 44, 50, 9, 49, 19, 3, 29, 35, 62, 12, 24, 7, 18, 52, 32, 10, 46, 21, 41, 32, 11, 36, 29, 14, 34, 60, 38, 54, 11, 41, 14, 19, 57, 32, 16, 7, 41, 51, 25, 14, 57 },
{ 53, 18, 26, 50, 15, 58, 4, 63, 17, 43, 7, 40, 61, 35, 15, 41, 23, 60, 16, 38, 14, 42, 19, 50, 0, 31, 10, 46, 27, 63, 18, 60, 0, 20, 29, 39, 8, 26, 37, 5, 42, 0, 44, 39, 57, 17, 58, 41, 28, 37, 4, 32, 9, 44, 12, 31, 54, 10, 59, 14, 27, 53, 12, 36, 0, 47, 13, 64, 21, 58, 10, 24, 50, 27, 4, 26, 44, 53, 31, 0, 18, 42, 29, 33, 57, 4, 32, 26, 0, 38, 16, 61, 41, 53, 20, 0, 42, 44, 49, 27, 10, 56, 39, 0, 57, 15, 53, 49, 3, 61, 22, 47, 17, 5, 49, 26, 2, 63, 39, 10, 47, 27, 37, 23, 4, 59, 38, 10 }, { 53, 18, 26, 50, 15, 58, 4, 63, 17, 43, 7, 40, 61, 35, 15, 41, 23, 60, 16, 38, 14, 42, 19, 50, 0, 31, 10, 46, 27, 63, 18, 60, 0, 20, 29, 39, 8, 26, 37, 5, 42, 0, 44, 39, 57, 17, 58, 41, 28, 37, 4, 32, 9, 44, 12, 31, 54, 10, 59, 14, 27, 53, 12, 36, 0, 47, 13, 63, 21, 58, 10, 24, 50, 27, 4, 26, 44, 53, 31, 0, 18, 42, 29, 33, 57, 4, 32, 26, 0, 38, 16, 61, 41, 53, 20, 0, 42, 44, 49, 27, 10, 56, 39, 0, 57, 15, 53, 49, 3, 61, 22, 47, 17, 5, 49, 26, 2, 63, 39, 10, 47, 27, 37, 23, 4, 59, 38, 10 },
{ 23, 39, 61, 3, 37, 28, 48, 31, 0, 34, 51, 23, 2, 26, 58, 0, 53, 11, 46, 1, 57, 29, 52, 14, 37, 61, 21, 35, 2, 49, 7, 34, 47, 55, 4, 33, 54, 13, 58, 52, 19, 50, 22, 7, 13, 29, 36, 11, 51, 17, 60, 25, 55, 4, 34, 51, 0, 35, 20, 48, 32, 3, 51, 30, 59, 28, 40, 3, 46, 29, 54, 43, 7, 62, 47, 11, 39, 4, 23, 46, 55, 8, 63, 5, 25, 37, 18, 46, 21, 56, 31, 5, 36, 8, 45, 58, 26, 15, 2, 36, 47, 21, 29, 44, 25, 34, 3, 27, 43, 10, 52, 0, 45, 30, 24, 36, 43, 18, 34, 59, 0, 52, 61, 15, 44, 19, 30, 49 }, { 23, 39, 61, 3, 37, 28, 48, 31, 0, 34, 51, 23, 2, 26, 58, 0, 53, 11, 46, 1, 57, 29, 52, 14, 37, 61, 21, 35, 2, 49, 7, 34, 47, 55, 4, 33, 54, 13, 58, 52, 19, 50, 22, 7, 13, 29, 36, 11, 51, 17, 60, 25, 55, 4, 34, 51, 0, 35, 20, 48, 32, 3, 51, 30, 59, 28, 40, 3, 46, 29, 54, 43, 7, 62, 47, 11, 39, 4, 23, 46, 55, 8, 63, 5, 25, 37, 18, 46, 21, 56, 31, 5, 36, 8, 45, 58, 26, 15, 2, 36, 47, 21, 29, 44, 25, 34, 3, 27, 43, 10, 52, 0, 45, 30, 24, 36, 43, 18, 34, 59, 0, 52, 61, 15, 44, 19, 30, 49 },
{ 0, 27, 12, 43, 54, 9, 22, 53, 21, 46, 15, 55, 29, 47, 20, 33, 39, 28, 59, 35, 9, 44, 5, 24, 47, 7, 52, 17, 56, 22, 30, 42, 14, 26, 45, 18, 49, 1, 24, 34, 11, 27, 55, 32, 61, 47, 2, 56, 6, 44, 13, 47, 36, 27, 58, 22, 16, 47, 40, 4, 57, 38, 21, 45, 16, 9, 56, 26, 11, 38, 0, 22, 36, 17, 33, 57, 16, 30, 62, 15, 35, 40, 20, 45, 59, 10, 54, 8, 63, 13, 52, 27, 22, 57, 28, 12, 32, 51, 55, 22, 63, 4, 16, 54, 12, 62, 45, 19, 58, 13, 32, 40, 20, 56, 7, 57, 9, 54, 6, 29, 42, 21, 8, 55, 35, 47, 6, 41 }, { 0, 27, 12, 43, 54, 9, 22, 53, 21, 46, 15, 55, 29, 47, 20, 33, 39, 28, 59, 35, 9, 44, 5, 24, 47, 7, 52, 17, 56, 22, 30, 42, 14, 26, 45, 18, 49, 1, 24, 34, 11, 27, 55, 32, 61, 47, 2, 56, 6, 44, 13, 47, 36, 27, 58, 22, 16, 47, 40, 4, 57, 38, 21, 45, 16, 9, 56, 26, 11, 38, 0, 22, 36, 17, 33, 57, 16, 30, 62, 15, 35, 40, 20, 45, 59, 10, 54, 8, 63, 13, 52, 27, 22, 57, 28, 12, 32, 51, 55, 22, 63, 4, 16, 54, 12, 62, 45, 19, 58, 13, 32, 40, 20, 56, 7, 57, 9, 54, 6, 29, 42, 21, 8, 55, 35, 47, 6, 41 },
{ 56, 33, 58, 32, 19, 35, 42, 6, 59, 11, 38, 5, 49, 12, 62, 7, 52, 17, 5, 25, 54, 20, 61, 31, 54, 27, 41, 11, 44, 5, 59, 12, 36, 51, 10, 61, 28, 41, 48, 9, 43, 63, 5, 40, 20, 8, 49, 26, 34, 21, 58, 1, 18, 45, 7, 39, 61, 26, 8, 50, 23, 10, 63, 5, 55, 37, 19, 49, 52, 15, 59, 47, 13, 54, 1, 25, 42, 58, 10, 48, 3, 27, 50, 1, 17, 48, 34, 41, 16, 40, 2, 45, 10, 39, 17, 61, 5, 38, 19, 9, 41, 31, 60, 38, 5, 23, 36, 8, 30, 55, 24, 63, 12, 48, 14, 51, 31, 20, 45, 25, 12, 50, 32, 2, 28, 11, 62, 14 }, { 56, 33, 58, 32, 19, 35, 42, 6, 59, 11, 38, 5, 49, 12, 62, 7, 52, 17, 5, 25, 54, 20, 61, 31, 54, 27, 41, 11, 44, 5, 59, 12, 36, 51, 10, 61, 28, 41, 48, 9, 43, 63, 5, 40, 20, 8, 49, 26, 34, 21, 58, 1, 18, 45, 7, 39, 61, 26, 8, 50, 23, 10, 63, 5, 55, 37, 19, 49, 52, 15, 59, 47, 13, 54, 1, 25, 42, 58, 10, 48, 3, 27, 50, 1, 17, 48, 34, 41, 16, 40, 2, 45, 10, 39, 17, 61, 5, 38, 19, 9, 41, 31, 60, 38, 5, 23, 36, 8, 30, 55, 24, 63, 12, 48, 14, 51, 31, 20, 45, 25, 12, 50, 32, 2, 28, 11, 62, 14 },
@ -910,13 +950,13 @@ static guchar DM[128][128] =
#define DM_HEIGHT 8 #define DM_HEIGHT 8
static guchar DM[8][8] = static guchar DM[8][8] =
{ {
{ 0, 32, 8, 40, 2, 34, 10, 42 }, { 0, 32, 8, 40, 2, 34, 10, 42 },
{ 48, 16, 56, 24, 50, 18, 58, 26 }, { 48, 16, 56, 24, 50, 18, 58, 26 },
{ 12, 44, 4, 36, 14, 46, 6, 38 }, { 12, 44, 4, 36, 14, 46, 6, 38 },
{ 60, 28, 52, 20, 62, 30, 54, 22 }, { 60, 28, 52, 20, 62, 30, 54, 22 },
{ 3, 35, 11, 43, 1, 33, 9, 41 }, { 3, 35, 11, 43, 1, 33, 9, 41 },
{ 51, 19, 59, 27, 49, 17, 57, 25 }, { 51, 19, 59, 27, 49, 17, 57, 25 },
{ 15, 47, 7, 39, 13, 45, 5, 37 }, { 15, 47, 7, 39, 13, 45, 5, 37 },
{ 63, 31, 55, 23, 61, 29, 53, 21 } { 63, 31, 55, 23, 61, 29, 53, 21 }
}; };
#endif #endif
@ -937,7 +977,7 @@ gdk_rgb_preprocess_dm_565 (void)
dith = DM[0][i] >> 3; dith = DM[0][i] >> 3;
DM_565[i] = (dith << 20) | dith | (((7 - dith) >> 1) << 10); DM_565[i] = (dith << 20) | dith | (((7 - dith) >> 1) << 10);
#ifdef VERBOSE #ifdef VERBOSE
g_message ("%i %x %x", i, dith, DM_565[i]); g_print ("%i %x %x\n", i, dith, DM_565[i]);
#endif #endif
} }
} }
@ -1144,7 +1184,7 @@ gdk_rgb_convert_565 (GdkImage *image,
{ {
bp2 = bptr; bp2 = bptr;
obptr = obuf; obptr = obuf;
if (width < 8 || (((unsigned long)obuf | (unsigned long) bp2) & 3)) if (((unsigned long)obuf | (unsigned long) bp2) & 3)
{ {
for (x = 0; x < width; x++) for (x = 0; x < width; x++)
{ {
@ -1275,7 +1315,7 @@ gdk_rgb_convert_565_gray (GdkImage *image,
{ {
bp2 = bptr; bp2 = bptr;
obptr = obuf; obptr = obuf;
if (width < 8 || (((unsigned long)obuf | (unsigned long) bp2) & 3)) if (((unsigned long)obuf | (unsigned long) bp2) & 3)
{ {
for (x = 0; x < width; x++) for (x = 0; x < width; x++)
{ {
@ -1380,7 +1420,7 @@ gdk_rgb_convert_565_br (GdkImage *image,
b = *bp2++; b = *bp2++;
/* final word is: /* final word is:
g4 g3 g2 b7 b6 b5 b4 b3 r7 r6 r5 r4 r3 g7 g6 g5 g4 g3 g2 b7 b6 b5 b4 b3 r7 r6 r5 r4 r3 g7 g6 g5
*/ */
((unsigned short *)obuf)[x] = (r & 0xf8) | ((unsigned short *)obuf)[x] = (r & 0xf8) |
((g & 0xe0) >> 5) | ((g & 0xe0) >> 5) |
((g & 0x1c) << 11) | ((g & 0x1c) << 11) |
@ -1396,9 +1436,9 @@ gdk_rgb_convert_565_br (GdkImage *image,
#ifdef HAIRY_CONVERT_565 #ifdef HAIRY_CONVERT_565
static void static void
gdk_rgb_convert_565_d (GdkImage *image, gdk_rgb_convert_565_d (GdkImage *image,
gint x0, gint y0, gint width, gint height, gint x0, gint y0, gint width, gint height,
guchar *buf, int rowstride, guchar *buf, int rowstride,
gint x_align, gint y_align, GdkRgbCmap *cmap) gint x_align, gint y_align, GdkRgbCmap *cmap)
{ {
/* Now this is what I'd call some highly tuned code! */ /* Now this is what I'd call some highly tuned code! */
int x, y; int x, y;
@ -1417,7 +1457,7 @@ gdk_rgb_convert_565_d (GdkImage *image,
guint32 *dmp = DM_565 + ((y & (DM_HEIGHT - 1)) << DM_WIDTH_SHIFT); guint32 *dmp = DM_565 + ((y & (DM_HEIGHT - 1)) << DM_WIDTH_SHIFT);
bp2 = bptr; bp2 = bptr;
obptr = obuf; obptr = obuf;
if (width < 8 || (((unsigned long)obuf | (unsigned long) bp2) & 3)) if (((unsigned long)obuf | (unsigned long) bp2) & 3)
{ {
for (x = x_align; x < width; x++) for (x = x_align; x < width; x++)
{ {
@ -1429,7 +1469,7 @@ gdk_rgb_convert_565_d (GdkImage *image,
- ((rgb & 0x1e0001e0) >> 5) - ((rgb & 0x1e0001e0) >> 5)
- ((rgb & 0x00070000) >> 6); - ((rgb & 0x00070000) >> 6);
((unsigned short *)obuf)[0] = ((unsigned short *)obptr)[0] =
((rgb & 0x0f800000) >> 12) | ((rgb & 0x0f800000) >> 12) |
((rgb & 0x0003f000) >> 7) | ((rgb & 0x0003f000) >> 7) |
((rgb & 0x000000f8) >> 3); ((rgb & 0x000000f8) >> 3);
@ -1507,7 +1547,7 @@ gdk_rgb_convert_565_d (GdkImage *image,
- ((rgb & 0x1e0001e0) >> 5) - ((rgb & 0x1e0001e0) >> 5)
- ((rgb & 0x00070000) >> 6); - ((rgb & 0x00070000) >> 6);
((unsigned short *)obuf)[0] = ((unsigned short *)obptr)[0] =
((rgb & 0x0f800000) >> 12) | ((rgb & 0x0f800000) >> 12) |
((rgb & 0x0003f000) >> 7) | ((rgb & 0x0003f000) >> 7) |
((rgb & 0x000000f8) >> 3); ((rgb & 0x000000f8) >> 3);
@ -1521,9 +1561,9 @@ gdk_rgb_convert_565_d (GdkImage *image,
#else #else
static void static void
gdk_rgb_convert_565_d (GdkImage *image, gdk_rgb_convert_565_d (GdkImage *image,
gint x0, gint y0, gint width, gint height, gint x0, gint y0, gint width, gint height,
guchar *buf, int rowstride, guchar *buf, int rowstride,
gint x_align, gint y_align, GdkRgbCmap *cmap) gint x_align, gint y_align, GdkRgbCmap *cmap)
{ {
int x, y; int x, y;
guchar *obuf; guchar *obuf;
@ -1543,20 +1583,20 @@ gdk_rgb_convert_565_d (GdkImage *image,
guchar *bp2 = bptr; guchar *bp2 = bptr;
for (x = x_align; x < width; x++) for (x = x_align; x < width; x++)
{ {
gint32 rgb = *bp2++ << 20; gint32 rgb = *bp2++ << 20;
rgb += *bp2++ << 10; rgb += *bp2++ << 10;
rgb += *bp2++; rgb += *bp2++;
rgb += dmp[x & (DM_WIDTH - 1)]; rgb += dmp[x & (DM_WIDTH - 1)];
rgb += 0x10040100 rgb += 0x10040100
- ((rgb & 0x1e0001e0) >> 5) - ((rgb & 0x1e0001e0) >> 5)
- ((rgb & 0x00070000) >> 6); - ((rgb & 0x00070000) >> 6);
((unsigned short *)obuf)[x] = ((unsigned short *)obuf)[x] =
((rgb & 0x0f800000) >> 12) | ((rgb & 0x0f800000) >> 12) |
((rgb & 0x0003f000) >> 7) | ((rgb & 0x0003f000) >> 7) |
((rgb & 0x000000f8) >> 3); ((rgb & 0x000000f8) >> 3);
} }
bptr += rowstride; bptr += rowstride;
obuf += bpl; obuf += bpl;
@ -1621,7 +1661,7 @@ gdk_rgb_convert_555_br (GdkImage *image,
b = *bp2++; b = *bp2++;
/* final word is: /* final word is:
g5 g4 g3 b7 b6 b5 b4 b3 0 r7 r6 r5 r4 r3 g7 g6 g5 g4 g3 b7 b6 b5 b4 b3 0 r7 r6 r5 r4 r3 g7 g6
*/ */
((unsigned short *)obuf)[x] = ((r & 0xf8) >> 1) | ((unsigned short *)obuf)[x] = ((r & 0xf8) >> 1) |
((g & 0xc0) >> 6) | ((g & 0xc0) >> 6) |
((g & 0x18) << 10) | ((g & 0x18) << 10) |
@ -1679,7 +1719,7 @@ gdk_rgb_convert_888_lsb (GdkImage *image,
{ {
bp2 = bptr; bp2 = bptr;
obptr = obuf; obptr = obuf;
if (width < 8 || (((unsigned long)obuf | (unsigned long) bp2) & 3)) if (((unsigned long)obuf | (unsigned long) bp2) & 3)
{ {
for (x = 0; x < width; x++) for (x = 0; x < width; x++)
{ {
@ -2068,6 +2108,70 @@ gdk_rgb_convert_truecolor_msb_d (GdkImage *image,
} }
} }
#define IMAGE_8BPP
static void
gdk_rgb_convert_4 (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 pix0, pix1;
bptr = buf;
bpl = image->bpl;
obuf = ((guchar *)image->mem) + y0 * bpl + x0;
for (y = 0; y < height; y++)
{
dmp = DM[(y_align + y) & (DM_HEIGHT - 1)];
bp2 = bptr;
obptr = obuf;
#ifdef IMAGE_8BPP
for (x = 0; x < width; x += 1)
{
r = *bp2++;
g = *bp2++;
b = *bp2++;
dith = (dmp[(x_align + x) & (DM_WIDTH - 1)] << 2) | 3;
obptr[0] = colorcube_d[(((r + dith) & 0x100) >> 2) |
(((g + 258 - dith) & 0x100) >> 5) |
(((b + dith) & 0x100) >> 8)];
obptr++;
}
#else
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)];
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)];
obptr[0] = (pix0 << 4) | pix1;
obptr++;
}
#endif
bptr += rowstride;
obuf += bpl;
}
}
/* Returns a pointer to the stage buffer. */ /* Returns a pointer to the stage buffer. */
static guchar * static guchar *
gdk_rgb_ensure_stage (void) gdk_rgb_ensure_stage (void)
@ -2203,9 +2307,9 @@ gdk_rgb_convert_gray_cmap (GdkImage *image,
#if 0 #if 0
static void static void
gdk_rgb_convert_gray_cmap_d (GdkImage *image, gdk_rgb_convert_gray_cmap_d (GdkImage *image,
gint x0, gint y0, gint width, gint height, gint x0, gint y0, gint width, gint height,
guchar *buf, gint rowstride, guchar *buf, gint rowstride,
gint x_align, gint y_align, GdkRgbCmap *cmap) gint x_align, gint y_align, GdkRgbCmap *cmap)
{ {
(*image_info->conv_indexed_d) (image, x0, y0, width, height, (*image_info->conv_indexed_d) (image, x0, y0, width, height,
buf, rowstride, buf, rowstride,
@ -2327,17 +2431,17 @@ gdk_rgb_select_conv (GdkImage *image)
} }
else if (bpp == 2 && depth == 16 && else if (bpp == 2 && depth == 16 &&
vtype == GDK_VISUAL_TRUE_COLOR && byterev && vtype == GDK_VISUAL_TRUE_COLOR && byterev &&
red_mask == 0xf800 && green_mask == 0x7e0 && blue_mask == 0x1f) red_mask == 0xf800 && green_mask == 0x7e0 && blue_mask == 0x1f)
conv = gdk_rgb_convert_565_br; conv = gdk_rgb_convert_565_br;
else if (bpp == 2 && depth == 15 && else if (bpp == 2 && depth == 15 &&
vtype == GDK_VISUAL_TRUE_COLOR && !byterev && vtype == GDK_VISUAL_TRUE_COLOR && !byterev &&
red_mask == 0x7c00 && green_mask == 0x3e0 && blue_mask == 0x1f) red_mask == 0x7c00 && green_mask == 0x3e0 && blue_mask == 0x1f)
conv = gdk_rgb_convert_555; conv = gdk_rgb_convert_555;
else if (bpp == 2 && depth == 15 && else if (bpp == 2 && depth == 15 &&
vtype == GDK_VISUAL_TRUE_COLOR && byterev && vtype == GDK_VISUAL_TRUE_COLOR && byterev &&
red_mask == 0x7c00 && green_mask == 0x3e0 && blue_mask == 0x1f) red_mask == 0x7c00 && green_mask == 0x3e0 && blue_mask == 0x1f)
conv = gdk_rgb_convert_555_br; conv = gdk_rgb_convert_555_br;
/* I'm not 100% sure about the 24bpp tests */ /* I'm not 100% sure about the 24bpp tests */
@ -2397,6 +2501,10 @@ gdk_rgb_select_conv (GdkImage *image)
conv = gdk_rgb_convert_gray8; conv = gdk_rgb_convert_gray8;
conv_gray = gdk_rgb_convert_gray8_gray; conv_gray = gdk_rgb_convert_gray8_gray;
} }
else if (depth == 4)
{
conv = gdk_rgb_convert_4;
}
if (conv_d == NULL) if (conv_d == NULL)
conv_d = conv; conv_d = conv;
@ -2441,7 +2549,7 @@ gdk_rgb_alloc_scratch_image (void)
gdk_flush (); gdk_flush ();
#endif #endif
#ifdef VERBOSE #ifdef VERBOSE
g_message ("flush, %d puts since last flush", sincelast); g_print ("flush, %d puts since last flush\n", sincelast);
sincelast = 0; sincelast = 0;
#endif #endif
static_image_idx = 0; static_image_idx = 0;
@ -2519,7 +2627,7 @@ gdk_rgb_alloc_scratch (gint width, gint height, gint *x0, gint *y0)
} }
image = static_image[idx]; image = static_image[idx];
#ifdef VERBOSE #ifdef VERBOSE
g_message ("index %d, x %d, y %d (%d x %d)", idx, *x0, *y0, width, height); g_print ("index %d, x %d, y %d (%d x %d)\n", idx, *x0, *y0, width, height);
sincelast++; sincelast++;
#endif #endif
return image; return image;
@ -2615,7 +2723,7 @@ gdk_rgb_make_gray_cmap (GdkRgbInfo *info)
gint i; gint i;
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
rgb[i] = (i << 16) | (i << 8) | i; rgb[i] = (i << 16) | (i << 8) | i;
info->gray_cmap = gdk_rgb_cmap_new (rgb, 256); info->gray_cmap = gdk_rgb_cmap_new (rgb, 256);
} }
@ -2665,10 +2773,10 @@ gdk_rgb_cmap_new (guint32 *colors, gint n_colors)
{ {
rgb = colors[i]; rgb = colors[i];
j = ((rgb & 0xf00000) >> 12) | j = ((rgb & 0xf00000) >> 12) |
((rgb & 0xf000) >> 8) | ((rgb & 0xf000) >> 8) |
((rgb & 0xf0) >> 4); ((rgb & 0xf0) >> 4);
#ifdef VERBOSE #ifdef VERBOSE
g_message ("%d %x %x %d", i, j, colorcube[j]); g_print ("%d %x %x %d\n", i, j, colorcube[j]);
#endif #endif
cmap->lut[i] = colorcube[j]; cmap->lut[i] = colorcube[j];
} }

File diff suppressed because it is too large Load Diff

View File

@ -46,6 +46,11 @@ struct _GtkPreview
guint16 buffer_width; guint16 buffer_width;
guint16 buffer_height; guint16 buffer_height;
guint16 bpp;
guint16 rowstride;
GdkRgbDither dither;
guint type : 1; guint type : 1;
guint expand : 1; guint expand : 1;
}; };
@ -55,28 +60,8 @@ struct _GtkPreviewInfo
GdkVisual *visual; GdkVisual *visual;
GdkColormap *cmap; GdkColormap *cmap;
gulong *color_pixels; guchar *lookup;
gulong *gray_pixels;
gulong *reserved_pixels;
gulong *lookup_red;
gulong *lookup_green;
gulong *lookup_blue;
GtkDitherInfo *dither_red;
GtkDitherInfo *dither_green;
GtkDitherInfo *dither_blue;
GtkDitherInfo *dither_gray;
guchar ***dither_matrix;
guint nred_shades;
guint ngreen_shades;
guint nblue_shades;
guint ngray_shades;
guint nreserved;
guint bpp;
gint cmap_alloced;
gdouble gamma; gdouble gamma;
}; };
@ -92,7 +77,6 @@ struct _GtkPreviewClass
GtkPreviewInfo info; GtkPreviewInfo info;
GdkImage *image;
}; };
@ -111,6 +95,7 @@ void gtk_preview_put (GtkPreview *preview,
gint desty, gint desty,
gint width, gint width,
gint height); gint height);
/* gtk_preview_put_row is broken */
void gtk_preview_put_row (GtkPreview *preview, void gtk_preview_put_row (GtkPreview *preview,
guchar *src, guchar *src,
guchar *dest, guchar *dest,
@ -132,6 +117,8 @@ void gtk_preview_set_color_cube (guint nred_shades,
guint ngray_shades); guint ngray_shades);
void gtk_preview_set_install_cmap (gint install_cmap); void gtk_preview_set_install_cmap (gint install_cmap);
void gtk_preview_set_reserved (gint nreserved); void gtk_preview_set_reserved (gint nreserved);
void gtk_preview_set_dither (GtkPreview *preview,
GdkRgbDither dither);
GdkVisual* gtk_preview_get_visual (void); GdkVisual* gtk_preview_get_visual (void);
GdkColormap* gtk_preview_get_cmap (void); GdkColormap* gtk_preview_get_cmap (void);
GtkPreviewInfo* gtk_preview_get_info (void); GtkPreviewInfo* gtk_preview_get_info (void);