This is the integration of GdkRgb into Gimp.

This commit is contained in:
Raph Levien
1998-08-20 06:46:07 +00:00
parent d4936d20a4
commit 65ae5245d0
13 changed files with 516 additions and 5429 deletions

View File

@ -1,3 +1,27 @@
1998-08-19 Raph Levien <raph@gimp.org>
This is the GdkRgb integration.
* app/gximage.c (gximage_put): Uses gdk_draw_rgb_image rather
than gdk_draw_image.
* app/image_render.c: gutted most of this, as it is now subsumed
by GdkRgb. In the process, gamma != 1.0 doesn't work anymore.
Also, speedups are almost certainly possible in a bunch of cases.
* app/info_window.c (get_shades): compiles and runs, but is
not functional.
* app/colormaps.c: gutted
* app/color_select.c: changed dither to max
A few things remain: the dithering is _not_ correctly aligned for
scrolling - looks like I'll need to add some more API to GdkRgb
for that. The gradient editor needs to be set to maximum
dithering. I'd like to draw the foreground and background colors
dithered so they don't quantize so much in 8bpp modes.
Wed Aug 19 21:00:00 PDT 1998 Ray Lehtiniemi <rayl@netrover.com> Wed Aug 19 21:00:00 PDT 1998 Ray Lehtiniemi <rayl@netrover.com>
* app/airbrush.c gdisplay.c gimage.h gimpimage.c gimpimage.h * app/airbrush.c gdisplay.c gimage.h gimpimage.c gimpimage.h

View File

@ -206,6 +206,7 @@ color_select_new (int r,
gtk_widget_show (xy_frame); gtk_widget_show (xy_frame);
csp->xy_color = gtk_preview_new (GTK_PREVIEW_COLOR); csp->xy_color = gtk_preview_new (GTK_PREVIEW_COLOR);
gtk_preview_set_dither (GTK_PREVIEW (csp->xy_color), GDK_RGB_DITHER_MAX);
gtk_preview_size (GTK_PREVIEW (csp->xy_color), XY_DEF_WIDTH, XY_DEF_HEIGHT); gtk_preview_size (GTK_PREVIEW (csp->xy_color), XY_DEF_WIDTH, XY_DEF_HEIGHT);
gtk_widget_set_events (csp->xy_color, COLOR_AREA_MASK); gtk_widget_set_events (csp->xy_color, COLOR_AREA_MASK);
gtk_signal_connect_after (GTK_OBJECT (csp->xy_color), "expose_event", gtk_signal_connect_after (GTK_OBJECT (csp->xy_color), "expose_event",
@ -223,6 +224,7 @@ color_select_new (int r,
gtk_widget_show (z_frame); gtk_widget_show (z_frame);
csp->z_color = gtk_preview_new (GTK_PREVIEW_COLOR); csp->z_color = gtk_preview_new (GTK_PREVIEW_COLOR);
gtk_preview_set_dither (GTK_PREVIEW (csp->z_color), GDK_RGB_DITHER_MAX);
gtk_preview_size (GTK_PREVIEW (csp->z_color), Z_DEF_WIDTH, Z_DEF_HEIGHT); gtk_preview_size (GTK_PREVIEW (csp->z_color), Z_DEF_WIDTH, Z_DEF_HEIGHT);
gtk_widget_set_events (csp->z_color, COLOR_AREA_MASK); gtk_widget_set_events (csp->z_color, COLOR_AREA_MASK);
gtk_signal_connect_after (GTK_OBJECT (csp->z_color), "expose_event", gtk_signal_connect_after (GTK_OBJECT (csp->z_color), "expose_event",

View File

@ -65,9 +65,6 @@ gulong *g_lookup_blue;
gulong *color_pixel_vals; gulong *color_pixel_vals;
gulong *gray_pixel_vals; gulong *gray_pixel_vals;
static int reserved_entries = 4; /* extra colors aside from color cube */
static gulong *reserved_pixels;
static void make_color (gulong *pixel_ptr, static void make_color (gulong *pixel_ptr,
int red, int red,
int green, int green,
@ -77,20 +74,7 @@ static void make_color (gulong *pixel_ptr,
static void static void
set_app_colors () set_app_colors ()
{ {
int i; cycled_marching_ants = FALSE;
if ((g_visual->type == GDK_VISUAL_PSEUDO_COLOR) ||
(g_visual->type == GDK_VISUAL_GRAYSCALE))
{
foreground_pixel = reserved_pixels[0];
background_pixel = reserved_pixels[1];
old_color_pixel = reserved_pixels[2];
new_color_pixel = reserved_pixels[3];
}
else
{
cycled_marching_ants = FALSE;
}
make_color (&g_black_pixel, 0, 0, 0, FALSE); make_color (&g_black_pixel, 0, 0, 0, FALSE);
make_color (&g_gray_pixel, 127, 127, 127, FALSE); make_color (&g_gray_pixel, 127, 127, 127, FALSE);
@ -104,19 +88,9 @@ set_app_colors ()
store_color (&old_color_pixel, 0, 0, 0); store_color (&old_color_pixel, 0, 0, 0);
store_color (&new_color_pixel, 255, 255, 255); store_color (&new_color_pixel, 255, 255, 255);
/* marching ants pixels--if enabled */
if (cycled_marching_ants)
for (i = 0; i < 8; i++)
{
marching_ants_pixels[i] = reserved_pixels[i + reserved_entries - 8];
if (i < 4)
store_color (&marching_ants_pixels[i], 0, 0, 0);
else
store_color (&marching_ants_pixels[i], 255, 255, 255);
}
} }
/* This probably doesn't belong here - RLL*/
static unsigned int static unsigned int
gamma_correct (int intensity, double gamma) gamma_correct (int intensity, double gamma)
{ {
@ -144,17 +118,7 @@ get_color (int red,
int green, int green,
int blue) int blue)
{ {
gulong pixel; return gdk_rgb_xpixel_from_rgb ((red << 16) | (green << 8) | blue);
if ((g_visual->type == GDK_VISUAL_PSEUDO_COLOR) ||
(g_visual->type == GDK_VISUAL_GRAYSCALE))
pixel = color_pixel_vals [(red_ordered_dither[red].s[1] +
green_ordered_dither[green].s[1] +
blue_ordered_dither[blue].s[1])];
else
store_color (&pixel, red, green, blue);
return pixel;
} }
@ -165,24 +129,7 @@ make_color (gulong *pixel_ptr,
int blue, int blue,
int readwrite) int readwrite)
{ {
GdkColor col; *pixel_ptr = get_color (red, green, blue);
red = gamma_correct (red, gamma_val);
green = gamma_correct (green, gamma_val);
blue = gamma_correct (blue, gamma_val);
col.red = red * (65535 / 255);
col.green = green * (65535 / 255);
col.blue = blue * (65535 / 255);
col.pixel = *pixel_ptr;
if (readwrite && ((g_visual->type == GDK_VISUAL_PSEUDO_COLOR) ||
(g_visual->type == GDK_VISUAL_GRAYSCALE)))
gdk_color_change (g_cmap, &col);
else
gdk_color_alloc (g_cmap, &col);
*pixel_ptr = col.pixel;
} }
void void
@ -191,7 +138,7 @@ store_color (gulong *pixel_ptr,
int green, int green,
int blue) int blue)
{ {
make_color (pixel_ptr, red, green, blue, TRUE); *pixel_ptr = get_color (red, green, blue);
} }
@ -200,43 +147,14 @@ get_standard_colormaps ()
{ {
GtkPreviewInfo *info; GtkPreviewInfo *info;
if (cycled_marching_ants)
reserved_entries += 8;
gtk_preview_set_gamma (gamma_val);
gtk_preview_set_color_cube (color_cube_shades[0], color_cube_shades[1],
color_cube_shades[2], color_cube_shades[3]);
gtk_preview_set_install_cmap (install_cmap);
gtk_preview_set_reserved (reserved_entries);
/* so we can reinit the colormaps */
gtk_preview_reset ();
gtk_widget_set_default_visual (gtk_preview_get_visual ()); gtk_widget_set_default_visual (gtk_preview_get_visual ());
gtk_widget_set_default_colormap (gtk_preview_get_cmap ()); gtk_widget_set_default_colormap (gtk_preview_get_cmap ());
info = gtk_preview_get_info (); info = gtk_preview_get_info ();
g_visual = info->visual; g_visual = info->visual;
if (((g_visual->type == GDK_VISUAL_PSEUDO_COLOR) ||
(g_visual->type == GDK_VISUAL_GRAYSCALE)) &&
info->reserved_pixels == NULL) {
g_print("GIMP cannot get enough colormaps to boot.\n");
g_print("Try exiting other color intensive applications.\n");
g_print("Also try enabling the (install-colormap) option in gimprc.\n");
swapping_free ();
brushes_free ();
patterns_free ();
palettes_free ();
gradients_free ();
palette_free ();
procedural_db_free ();
plug_in_kill ();
tile_swap_exit ();
gtk_exit(0);
}
g_cmap = info->cmap; g_cmap = info->cmap;
#if 0
color_pixel_vals = info->color_pixels; color_pixel_vals = info->color_pixels;
gray_pixel_vals = info->gray_pixels; gray_pixel_vals = info->gray_pixels;
reserved_pixels = info->reserved_pixels; reserved_pixels = info->reserved_pixels;
@ -251,6 +169,7 @@ get_standard_colormaps ()
g_lookup_red = info->lookup_red; g_lookup_red = info->lookup_red;
g_lookup_green = info->lookup_green; g_lookup_green = info->lookup_green;
g_lookup_blue = info->lookup_blue; g_lookup_blue = info->lookup_blue;
#endif
set_app_colors (); set_app_colors ();
} }

View File

@ -57,6 +57,8 @@ static void
get_shades (GDisplay *gdisp, get_shades (GDisplay *gdisp,
char *buf) char *buf)
{ {
sprintf (buf, "Using GdkRgb - we'll get back to you");
#if 0
GtkPreviewInfo *info; GtkPreviewInfo *info;
info = gtk_preview_get_info (); info = gtk_preview_get_info ();
@ -91,6 +93,7 @@ get_shades (GDisplay *gdisp,
sprintf (buf, "%d", gdisp->gimage->num_cols); sprintf (buf, "%d", gdisp->gimage->num_cols);
break; break;
} }
#endif
} }
static void static void

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -31,7 +31,7 @@ struct _GXImage
GdkVisual *visual; /* visual appropriate to our depth */ GdkVisual *visual; /* visual appropriate to our depth */
GdkGC *gc; /* graphics context */ GdkGC *gc; /* graphics context */
GdkImage *image; /* private data */ guchar *data;
}; };
@ -52,7 +52,7 @@ create_gximage (GdkVisual *visual, int width, int height)
gximage->visual = visual; gximage->visual = visual;
gximage->gc = NULL; gximage->gc = NULL;
gximage->image = gdk_image_new (GDK_IMAGE_FASTEST, visual, width, height); gximage->data = g_malloc (width * height * 3);
return gximage; return gximage;
} }
@ -60,7 +60,7 @@ create_gximage (GdkVisual *visual, int width, int height)
static void static void
delete_gximage (GXImage *gximage) delete_gximage (GXImage *gximage)
{ {
gdk_image_destroy (gximage->image); g_free (gximage->data);
if (gximage->gc) if (gximage->gc)
gdk_gc_destroy (gximage->gc); gdk_gc_destroy (gximage->gc);
g_free (gximage); g_free (gximage);
@ -86,25 +86,25 @@ gximage_free ()
guchar* guchar*
gximage_get_data () gximage_get_data ()
{ {
return gximage->image->mem; return gximage->data;
} }
int int
gximage_get_bpp () gximage_get_bpp ()
{ {
return gximage->image->bpp; return 3;
} }
int int
gximage_get_bpl () gximage_get_bpl ()
{ {
return gximage->image->bpl; return 3 * GXIMAGE_WIDTH;
} }
int int
gximage_get_byte_order () gximage_get_byte_order ()
{ {
return gximage->image->byte_order; return GDK_MSB_FIRST;
} }
void void
@ -117,8 +117,13 @@ gximage_put (GdkWindow *win, int x, int y, int w, int h)
gdk_gc_set_exposures (gximage->gc, TRUE); gdk_gc_set_exposures (gximage->gc, TRUE);
} }
gdk_draw_image (win, gximage->gc, gximage->image, 0, 0, x, y, w, h); gdk_draw_rgb_image (win,
gximage->gc,
/* sync the draw image to make sure it has been displayed before continuing */ x,
gdk_flush (); y,
w,
h,
GDK_RGB_DITHER_MAX, /* todo: make configurable */
gximage->data,
GXIMAGE_WIDTH * 3);
} }

View File

@ -206,6 +206,7 @@ color_select_new (int r,
gtk_widget_show (xy_frame); gtk_widget_show (xy_frame);
csp->xy_color = gtk_preview_new (GTK_PREVIEW_COLOR); csp->xy_color = gtk_preview_new (GTK_PREVIEW_COLOR);
gtk_preview_set_dither (GTK_PREVIEW (csp->xy_color), GDK_RGB_DITHER_MAX);
gtk_preview_size (GTK_PREVIEW (csp->xy_color), XY_DEF_WIDTH, XY_DEF_HEIGHT); gtk_preview_size (GTK_PREVIEW (csp->xy_color), XY_DEF_WIDTH, XY_DEF_HEIGHT);
gtk_widget_set_events (csp->xy_color, COLOR_AREA_MASK); gtk_widget_set_events (csp->xy_color, COLOR_AREA_MASK);
gtk_signal_connect_after (GTK_OBJECT (csp->xy_color), "expose_event", gtk_signal_connect_after (GTK_OBJECT (csp->xy_color), "expose_event",
@ -223,6 +224,7 @@ color_select_new (int r,
gtk_widget_show (z_frame); gtk_widget_show (z_frame);
csp->z_color = gtk_preview_new (GTK_PREVIEW_COLOR); csp->z_color = gtk_preview_new (GTK_PREVIEW_COLOR);
gtk_preview_set_dither (GTK_PREVIEW (csp->z_color), GDK_RGB_DITHER_MAX);
gtk_preview_size (GTK_PREVIEW (csp->z_color), Z_DEF_WIDTH, Z_DEF_HEIGHT); gtk_preview_size (GTK_PREVIEW (csp->z_color), Z_DEF_WIDTH, Z_DEF_HEIGHT);
gtk_widget_set_events (csp->z_color, COLOR_AREA_MASK); gtk_widget_set_events (csp->z_color, COLOR_AREA_MASK);
gtk_signal_connect_after (GTK_OBJECT (csp->z_color), "expose_event", gtk_signal_connect_after (GTK_OBJECT (csp->z_color), "expose_event",

View File

@ -57,6 +57,8 @@ static void
get_shades (GDisplay *gdisp, get_shades (GDisplay *gdisp,
char *buf) char *buf)
{ {
sprintf (buf, "Using GdkRgb - we'll get back to you");
#if 0
GtkPreviewInfo *info; GtkPreviewInfo *info;
info = gtk_preview_get_info (); info = gtk_preview_get_info ();
@ -91,6 +93,7 @@ get_shades (GDisplay *gdisp,
sprintf (buf, "%d", gdisp->gimage->num_cols); sprintf (buf, "%d", gdisp->gimage->num_cols);
break; break;
} }
#endif
} }
static void static void

View File

@ -31,7 +31,7 @@ struct _GXImage
GdkVisual *visual; /* visual appropriate to our depth */ GdkVisual *visual; /* visual appropriate to our depth */
GdkGC *gc; /* graphics context */ GdkGC *gc; /* graphics context */
GdkImage *image; /* private data */ guchar *data;
}; };
@ -52,7 +52,7 @@ create_gximage (GdkVisual *visual, int width, int height)
gximage->visual = visual; gximage->visual = visual;
gximage->gc = NULL; gximage->gc = NULL;
gximage->image = gdk_image_new (GDK_IMAGE_FASTEST, visual, width, height); gximage->data = g_malloc (width * height * 3);
return gximage; return gximage;
} }
@ -60,7 +60,7 @@ create_gximage (GdkVisual *visual, int width, int height)
static void static void
delete_gximage (GXImage *gximage) delete_gximage (GXImage *gximage)
{ {
gdk_image_destroy (gximage->image); g_free (gximage->data);
if (gximage->gc) if (gximage->gc)
gdk_gc_destroy (gximage->gc); gdk_gc_destroy (gximage->gc);
g_free (gximage); g_free (gximage);
@ -86,25 +86,25 @@ gximage_free ()
guchar* guchar*
gximage_get_data () gximage_get_data ()
{ {
return gximage->image->mem; return gximage->data;
} }
int int
gximage_get_bpp () gximage_get_bpp ()
{ {
return gximage->image->bpp; return 3;
} }
int int
gximage_get_bpl () gximage_get_bpl ()
{ {
return gximage->image->bpl; return 3 * GXIMAGE_WIDTH;
} }
int int
gximage_get_byte_order () gximage_get_byte_order ()
{ {
return gximage->image->byte_order; return GDK_MSB_FIRST;
} }
void void
@ -117,8 +117,13 @@ gximage_put (GdkWindow *win, int x, int y, int w, int h)
gdk_gc_set_exposures (gximage->gc, TRUE); gdk_gc_set_exposures (gximage->gc, TRUE);
} }
gdk_draw_image (win, gximage->gc, gximage->image, 0, 0, x, y, w, h); gdk_draw_rgb_image (win,
gximage->gc,
/* sync the draw image to make sure it has been displayed before continuing */ x,
gdk_flush (); y,
w,
h,
GDK_RGB_DITHER_MAX, /* todo: make configurable */
gximage->data,
GXIMAGE_WIDTH * 3);
} }

File diff suppressed because it is too large Load Diff

View File

@ -57,6 +57,8 @@ static void
get_shades (GDisplay *gdisp, get_shades (GDisplay *gdisp,
char *buf) char *buf)
{ {
sprintf (buf, "Using GdkRgb - we'll get back to you");
#if 0
GtkPreviewInfo *info; GtkPreviewInfo *info;
info = gtk_preview_get_info (); info = gtk_preview_get_info ();
@ -91,6 +93,7 @@ get_shades (GDisplay *gdisp,
sprintf (buf, "%d", gdisp->gimage->num_cols); sprintf (buf, "%d", gdisp->gimage->num_cols);
break; break;
} }
#endif
} }
static void static void

View File

@ -206,6 +206,7 @@ color_select_new (int r,
gtk_widget_show (xy_frame); gtk_widget_show (xy_frame);
csp->xy_color = gtk_preview_new (GTK_PREVIEW_COLOR); csp->xy_color = gtk_preview_new (GTK_PREVIEW_COLOR);
gtk_preview_set_dither (GTK_PREVIEW (csp->xy_color), GDK_RGB_DITHER_MAX);
gtk_preview_size (GTK_PREVIEW (csp->xy_color), XY_DEF_WIDTH, XY_DEF_HEIGHT); gtk_preview_size (GTK_PREVIEW (csp->xy_color), XY_DEF_WIDTH, XY_DEF_HEIGHT);
gtk_widget_set_events (csp->xy_color, COLOR_AREA_MASK); gtk_widget_set_events (csp->xy_color, COLOR_AREA_MASK);
gtk_signal_connect_after (GTK_OBJECT (csp->xy_color), "expose_event", gtk_signal_connect_after (GTK_OBJECT (csp->xy_color), "expose_event",
@ -223,6 +224,7 @@ color_select_new (int r,
gtk_widget_show (z_frame); gtk_widget_show (z_frame);
csp->z_color = gtk_preview_new (GTK_PREVIEW_COLOR); csp->z_color = gtk_preview_new (GTK_PREVIEW_COLOR);
gtk_preview_set_dither (GTK_PREVIEW (csp->z_color), GDK_RGB_DITHER_MAX);
gtk_preview_size (GTK_PREVIEW (csp->z_color), Z_DEF_WIDTH, Z_DEF_HEIGHT); gtk_preview_size (GTK_PREVIEW (csp->z_color), Z_DEF_WIDTH, Z_DEF_HEIGHT);
gtk_widget_set_events (csp->z_color, COLOR_AREA_MASK); gtk_widget_set_events (csp->z_color, COLOR_AREA_MASK);
gtk_signal_connect_after (GTK_OBJECT (csp->z_color), "expose_event", gtk_signal_connect_after (GTK_OBJECT (csp->z_color), "expose_event",