diff options
author | Havoc Pennington <hp@redhat.com> | 2001-06-04 23:15:51 +0000 |
---|---|---|
committer | Havoc Pennington <hp@src.gnome.org> | 2001-06-04 23:15:51 +0000 |
commit | 1b3c9214371d89a4872574d700b86cb71d6eee56 (patch) | |
tree | cc6c602393a292313c61da2b246b5a6b4de2ff4d /gdk-pixbuf/gdk-pixbuf-util.c | |
parent | 9cc992b6e732fef6edf2153821354a6b1b6a5af6 (diff) | |
download | gtk+-1b3c9214371d89a4872574d700b86cb71d6eee56.tar.gz |
Handle case where we need to parse the xsetting as if it were an RC file
2001-05-10 Havoc Pennington <hp@redhat.com>
* gtk/gtksettings.c (gtk_settings_get_property): Handle case where
we need to parse the xsetting as if it were an RC file string.
* gtk/gtkcolorsel.c (gtk_color_selection_class_init): load initial
value of palette from settings, not from static variable
* gdk/x11/gdkevents-x11.c: add color palette, toolbar mode to
xsettings translation table
* gtk/gtktoolbar.c (gtk_toolbar_new): Remove arguments, because
hardcoding the toolbar style conflicts with new customizable
toolbar style philosophy
(gtk_toolbar_class_init): add settings for default toolbar style;
these are used unless the app specifically forces a toolbar style
* gtk/gtksettings.c (settings_install_property_parser): only
return at the start if we warn and parser == NULL
* gtk/gtkcolorsel.c (gtk_color_selection_finalize): disconnect the
palette changed handler so we don't notify dead color selections
* gtk/gtkstyle.c (gtk_default_draw_shadow): handle
xthickness/ythickness of 0 or 1 properly
(gtk_default_draw_resize_grip): clear the background behind the
resize grips, and align to bottom right if we square the
area to be drawn.
* gtk/gtkstatusbar.c (gtk_statusbar_init): set horizontal usize on
statusbar label to 1, so it doesn't make toplevels resize oddly
(gtk_statusbar_size_request): add grip size to request
(gtk_statusbar_size_allocate): hack so the hbox still works with
the grip size in the request
* gtk/gtktoolbar.c (gtk_toolbar_show_all): override to fix
bug where showing all on a toplevel makes the toolbar
button text appear despite the toolbar mode
* gtk/gtkmenubar.c: add internal padding style property
* gtk/gtktoolbar.c: Add internal padding style property; add
shadow type style property
* gtk/gtkmenubar.c (gtk_menu_bar_paint): paint box with widget
state; and put Container::border_width outside the frame
* gtk/gtktextview.c: don't draw focus rectangle if we're in
interior focus mode, we just use blinking cursor
Diffstat (limited to 'gdk-pixbuf/gdk-pixbuf-util.c')
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf-util.c | 56 |
1 files changed, 35 insertions, 21 deletions
diff --git a/gdk-pixbuf/gdk-pixbuf-util.c b/gdk-pixbuf/gdk-pixbuf-util.c index 0f869b9471..16c32bb2b7 100644 --- a/gdk-pixbuf/gdk-pixbuf-util.c +++ b/gdk-pixbuf/gdk-pixbuf-util.c @@ -30,18 +30,20 @@ /** * gdk_pixbuf_add_alpha: * @pixbuf: A pixbuf. - * @substitute_color: Whether to substitute a color for zero opacity. If this + * @substitute_color: Whether to set a color to zero opacity. If this * is #FALSE, then the (@r, @g, @b) arguments will be ignored. * @r: Red value to substitute. * @g: Green value to substitute. * @b: Blue value to substitute. * - * Takes an existing pixbuf and adds an alpha channel to it. If the original - * pixbuf already had alpha information, then the contents of the new pixbuf are - * exactly the same as the original's. Otherwise, the new pixbuf will have all - * pixels with full opacity if @substitute_color is #FALSE. If - * @substitute_color is #TRUE, then the color specified by (@r, @g, @b) will be - * substituted for zero opacity. + * Takes an existing pixbuf and adds an alpha channel to it. + * If the existing pixbuf already had an alpha channel, the channel + * values are copied from the original; otherwise, the alpha channel + * is initialized to 255 (full opacity). + * + * If @substitute_color is #TRUE, then the color specified by (@r, @g, @b) will be + * assigned zero opacity. That is, if you pass (255, 255, 255) for the + * substitute color, all white pixels will become fully transparent. * * Return value: A newly-created pixbuf with a reference count of 1. **/ @@ -62,10 +64,12 @@ gdk_pixbuf_add_alpha (const GdkPixbuf *pixbuf, if (!new_pixbuf) return NULL; - return new_pixbuf; - } - - new_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, pixbuf->width, pixbuf->height); + if (!substitute_color) + return new_pixbuf; + } else { + new_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, pixbuf->width, pixbuf->height); + } + if (!new_pixbuf) return NULL; @@ -75,16 +79,26 @@ gdk_pixbuf_add_alpha (const GdkPixbuf *pixbuf, src = pixbuf->pixels + y * pixbuf->rowstride; dest = new_pixbuf->pixels + y * new_pixbuf->rowstride; - - for (x = 0; x < pixbuf->width; x++) { - tr = *dest++ = *src++; - tg = *dest++ = *src++; - tb = *dest++ = *src++; - - if (substitute_color && tr == r && tg == g && tb == b) - *dest++ = 0; - else - *dest++ = 255; + + if (pixbuf->has_alpha) { + /* Just subst color, we already copied everything else */ + for (x = 0; x < pixbuf->width; x++) { + if (src[0] == r && src[1] == g && src[2] == b) + dest[3] = 0; + src += 4; + dest += 4; + } + } else { + for (x = 0; x < pixbuf->width; x++) { + tr = *dest++ = *src++; + tg = *dest++ = *src++; + tb = *dest++ = *src++; + + if (substitute_color && tr == r && tg == g && tb == b) + *dest++ = 0; + else + *dest++ = 255; + } } } |