# HG changeset patch # User nenolod # Date 1166626763 28800 # Node ID c108a98794b14f12ae991c14e97b3ac66e79b553 # Parent 7d40f0a290b9ef973e2bc6bc540d9ddb32325f8c [svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine diff -r 7d40f0a290b9 -r c108a98794b1 ChangeLog --- a/ChangeLog Wed Dec 20 06:45:56 2006 -0800 +++ b/ChangeLog Wed Dec 20 06:59:23 2006 -0800 @@ -1,3 +1,13 @@ +2006-12-20 14:45:56 +0000 William Pitcock + revision [3373] + - break out string-related functions from util.c + + trunk/audacious/Makefile | 3 + trunk/audacious/strings.c | 384 ++++++++++++++++++++++++++++++++++++++++++++++ + trunk/audacious/util.c | 317 ------------------------------------- + 3 files changed, 386 insertions(+), 318 deletions(-) + + 2006-12-20 13:45:04 +0000 William Pitcock revision [3371] - fix list menu, reported by Joker diff -r 7d40f0a290b9 -r c108a98794b1 audacious/Makefile --- a/audacious/Makefile Wed Dec 20 06:45:56 2006 -0800 +++ b/audacious/Makefile Wed Dec 20 06:59:23 2006 -0800 @@ -76,7 +76,8 @@ iir_cfs.c \ iir_fpu.c \ signals.c \ - strings.c + strings.c \ + pixbuf_effects.c OBJECTS = ${SOURCES:.c=.o} diff -r 7d40f0a290b9 -r c108a98794b1 audacious/pixbuf_effects.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/audacious/pixbuf_effects.c Wed Dec 20 06:59:23 2006 -0800 @@ -0,0 +1,87 @@ +/* + * Audacious + * Copyright (c) 2006-2007 Audacious development team. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; under version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include + +#include "platform/smartinclude.h" +#include "util.h" + +#include + +static GdkPixbuf * +create_new_pixbuf (GdkPixbuf *src) +{ + g_return_val_if_fail (gdk_pixbuf_get_colorspace (src) == GDK_COLORSPACE_RGB, NULL); + g_return_val_if_fail ((!gdk_pixbuf_get_has_alpha (src) + && gdk_pixbuf_get_n_channels (src) == 3) + || (gdk_pixbuf_get_has_alpha (src) + && gdk_pixbuf_get_n_channels (src) == 4), NULL); + + return gdk_pixbuf_new (gdk_pixbuf_get_colorspace (src), + gdk_pixbuf_get_has_alpha (src), + gdk_pixbuf_get_bits_per_sample (src), + gdk_pixbuf_get_width (src), + gdk_pixbuf_get_height (src)); +} + +GdkPixbuf * +audacious_create_colorized_pixbuf (GdkPixbuf *src, + int red_value, + int green_value, + int blue_value) +{ + int i, j; + int width, height, has_alpha, src_row_stride, dst_row_stride; + guchar *target_pixels; + guchar *original_pixels; + guchar *pixsrc; + guchar *pixdest; + GdkPixbuf *dest; + + g_return_val_if_fail (gdk_pixbuf_get_colorspace (src) == GDK_COLORSPACE_RGB, NULL); + g_return_val_if_fail ((!gdk_pixbuf_get_has_alpha (src) + && gdk_pixbuf_get_n_channels (src) == 3) + || (gdk_pixbuf_get_has_alpha (src) + && gdk_pixbuf_get_n_channels (src) == 4), NULL); + g_return_val_if_fail (gdk_pixbuf_get_bits_per_sample (src) == 8, NULL); + + dest = create_new_pixbuf (src); + + has_alpha = gdk_pixbuf_get_has_alpha (src); + width = gdk_pixbuf_get_width (src); + height = gdk_pixbuf_get_height (src); + src_row_stride = gdk_pixbuf_get_rowstride (src); + dst_row_stride = gdk_pixbuf_get_rowstride (dest); + target_pixels = gdk_pixbuf_get_pixels (dest); + original_pixels = gdk_pixbuf_get_pixels (src); + + for (i = 0; i < height; i++) { + pixdest = target_pixels + i*dst_row_stride; + pixsrc = original_pixels + i*src_row_stride; + for (j = 0; j < width; j++) { + *pixdest++ = (*pixsrc++ * red_value) >> 8; + *pixdest++ = (*pixsrc++ * green_value) >> 8; + *pixdest++ = (*pixsrc++ * blue_value) >> 8; + if (has_alpha) { + *pixdest++ = *pixsrc++; + } + } + } + return dest; +} + diff -r 7d40f0a290b9 -r c108a98794b1 audacious/util.h --- a/audacious/util.h Wed Dec 20 06:45:56 2006 -0800 +++ b/audacious/util.h Wed Dec 20 06:59:23 2006 -0800 @@ -149,6 +149,7 @@ gchar *xmms_urldecode_path(const gchar * encoded_path); +GdkPixbuf *audacious_create_colorized_pixbuf(GdkPixbuf *src, gint red, gint green, gint blue); G_END_DECLS