diff options
author | Owen Taylor <otaylor@redhat.com> | 2000-07-02 17:03:21 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2000-07-02 17:03:21 +0000 |
commit | 4f1ccca5940937ca184c331e035c71ef84675193 (patch) | |
tree | 686f66036477376e3d6038eb75bd8b4943ec1459 /gdk/gdkpixbuf-render.c | |
parent | 7164c0acb138778fb973b0b48a70ff53d4a6e9b9 (diff) | |
download | gtk+-4f1ccca5940937ca184c331e035c71ef84675193.tar.gz |
Add gdk_rgb_find_color() to get a pixel value using GdkRGB functionality
Sun Jul 2 12:45:50 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdkrgb.[ch]: Add gdk_rgb_find_color() to get a pixel
value using GdkRGB functionality given GdkColormap and GdkColor.
(name not final, waiting for inspiration.)
* gdk/gdkgc.[ch] (gdk_gc_set_rgb_fg/bg_color): New functions to
set the foreground/background of a GC using the GC's colormap
and GdkRGB. (name not final, waiting for inspiration.)
* gdk/gdkcompat.h gdk/gdkrgb.c (gdk_rgb_get_colormap): Rename from
gdk_rgb_get_cmap(), put #define in gdkcompat.h.
* gtk/gtkwidget.[ch] gtkcompat.h: Make visuals for
gtk_widget_get_visual(), gtk_widget_get_default_visual, etc,
purely a function of the corresponding colormap. Make
gtk_widget_set_visual(), etc, noop macros in gtkcompat.h.
* gdk/gdkpixmap.c gdk/x11/gdkpixmap-c11.c: Rewrite
gdk_pixbuf_*create_from_xpm_* in terms of
gdk_pixbuf_new_from_xpm_data(), move into platform independent
code.
* gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable): Take
advantage of the new draw_rgb_32_image_dithalign.
* gdk/gdkrgb.c (gdk_draw_rgb_32_image_dithalign): Added.
* gtk/gtkgc.c (gtk_gc_new): Set the appropriate colormap
on each created GC.
* gdk/gdkgc.[ch]: Add gdk_gc_get/set_colormap.
* gdk/gdkgc.[ch]: Add a colormap field to the GdkGC structure
which we initialize from the drawable when the GC is created,
if the drawable has a colormap.
* gdk/x11/gdkgc-x11.c: include string.h for memset.
* gdk/x11/gdkinput-x11.c: include string.h for strlen, etc.
* gtk/gtklayout.[ch]: Remove unsed configure serial member.
Diffstat (limited to 'gdk/gdkpixbuf-render.c')
-rw-r--r-- | gdk/gdkpixbuf-render.c | 73 |
1 files changed, 20 insertions, 53 deletions
diff --git a/gdk/gdkpixbuf-render.c b/gdk/gdkpixbuf-render.c index 545f91123b..39bda4cc12 100644 --- a/gdk/gdkpixbuf-render.c +++ b/gdk/gdkpixbuf-render.c @@ -130,44 +130,6 @@ gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf, -/* Creates a buffer by stripping the alpha channel of a pixbuf */ -static guchar * -remove_alpha (GdkPixbuf *pixbuf, - int x, int y, - int width, int height, - int *rowstride) -{ - guchar *buf; - int xx, yy; - guchar *src, *dest; - - g_assert (pixbuf->n_channels == 4); - g_assert (pixbuf->has_alpha); - g_assert (width > 0 && height > 0); - g_assert (x >= 0 && x + width <= pixbuf->width); - g_assert (y >= 0 && y + height <= pixbuf->height); - - *rowstride = 4 * ((width * 3 + 3) / 4); - - buf = g_new (guchar, *rowstride * height); - - for (yy = 0; yy < height; yy++) - { - src = pixbuf->pixels + pixbuf->rowstride * (yy + y) + x * pixbuf->n_channels; - dest = buf + *rowstride * yy; - - for (xx = 0; xx < width; xx++) - { - *dest++ = *src++; - *dest++ = *src++; - *dest++ = *src++; - src++; - } - } - - return buf; -} - /** * gdk_pixbuf_render_to_drawable: * @pixbuf: A pixbuf. @@ -206,8 +168,8 @@ gdk_pixbuf_render_to_drawable (GdkPixbuf *pixbuf, GdkRgbDither dither, int x_dither, int y_dither) { - guchar *buf; int rowstride; + guchar *buf; g_return_if_fail (pixbuf != NULL); g_return_if_fail (pixbuf->colorspace == GDK_COLORSPACE_RGB); @@ -225,27 +187,32 @@ gdk_pixbuf_render_to_drawable (GdkPixbuf *pixbuf, return; /* This will have to be modified once we support other image types. - * Also, GdkRGB does not have gdk_draw_rgb_32_image_dithalign(), so we - * have to pack the buffer first. Sigh. */ - if (pixbuf->has_alpha) - buf = remove_alpha (pixbuf, src_x, src_y, width, height, &rowstride); - else + if (pixbuf->n_channels == 4) { buf = pixbuf->pixels + src_y * pixbuf->rowstride + src_x * 3; rowstride = pixbuf->rowstride; - } - gdk_draw_rgb_image_dithalign (drawable, gc, - dest_x, dest_y, - width, height, - dither, - buf, rowstride, - x_dither, y_dither); + gdk_draw_rgb_32_image_dithalign (drawable, gc, + dest_x, dest_y, + width, height, + dither, + buf, rowstride, + x_dither, y_dither); + } + else /* n_channels == 3 */ + { + buf = pixbuf->pixels + src_y * pixbuf->rowstride + src_x * 3; + rowstride = pixbuf->rowstride; - if (pixbuf->has_alpha) - g_free (buf); + gdk_draw_rgb_image_dithalign (drawable, gc, + dest_x, dest_y, + width, height, + dither, + buf, rowstride, + x_dither, y_dither); + } } |