Mercurial > audlegacy
annotate audacious/pixbuf_effects.c @ 2270:50dea14e2fa3 trunk
[svn] Serbian language upadated
author | kustodian |
---|---|
date | Thu, 04 Jan 2007 14:55:34 -0800 |
parents | c108a98794b1 |
children |
rev | line source |
---|---|
2185
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
1 /* |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
2 * Audacious |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
3 * Copyright (c) 2006-2007 Audacious development team. |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
4 * |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
5 * This program is free software; you can redistribute it and/or modify |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
6 * it under the terms of the GNU General Public License as published by |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
7 * the Free Software Foundation; under version 2 of the License. |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
8 * |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
9 * This program is distributed in the hope that it will be useful, |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
12 * GNU General Public License for more details. |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
13 * |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
14 * You should have received a copy of the GNU General Public License |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
15 * along with this program; if not, write to the Free Software |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
17 */ |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
18 |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
19 #include <glib.h> |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
20 |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
21 #include "platform/smartinclude.h" |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
22 #include "util.h" |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
23 |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
24 #include <gdk-pixbuf/gdk-pixbuf.h> |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
25 |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
26 static GdkPixbuf * |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
27 create_new_pixbuf (GdkPixbuf *src) |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
28 { |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
29 g_return_val_if_fail (gdk_pixbuf_get_colorspace (src) == GDK_COLORSPACE_RGB, NULL); |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
30 g_return_val_if_fail ((!gdk_pixbuf_get_has_alpha (src) |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
31 && gdk_pixbuf_get_n_channels (src) == 3) |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
32 || (gdk_pixbuf_get_has_alpha (src) |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
33 && gdk_pixbuf_get_n_channels (src) == 4), NULL); |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
34 |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
35 return gdk_pixbuf_new (gdk_pixbuf_get_colorspace (src), |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
36 gdk_pixbuf_get_has_alpha (src), |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
37 gdk_pixbuf_get_bits_per_sample (src), |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
38 gdk_pixbuf_get_width (src), |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
39 gdk_pixbuf_get_height (src)); |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
40 } |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
41 |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
42 GdkPixbuf * |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
43 audacious_create_colorized_pixbuf (GdkPixbuf *src, |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
44 int red_value, |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
45 int green_value, |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
46 int blue_value) |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
47 { |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
48 int i, j; |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
49 int width, height, has_alpha, src_row_stride, dst_row_stride; |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
50 guchar *target_pixels; |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
51 guchar *original_pixels; |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
52 guchar *pixsrc; |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
53 guchar *pixdest; |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
54 GdkPixbuf *dest; |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
55 |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
56 g_return_val_if_fail (gdk_pixbuf_get_colorspace (src) == GDK_COLORSPACE_RGB, NULL); |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
57 g_return_val_if_fail ((!gdk_pixbuf_get_has_alpha (src) |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
58 && gdk_pixbuf_get_n_channels (src) == 3) |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
59 || (gdk_pixbuf_get_has_alpha (src) |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
60 && gdk_pixbuf_get_n_channels (src) == 4), NULL); |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
61 g_return_val_if_fail (gdk_pixbuf_get_bits_per_sample (src) == 8, NULL); |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
62 |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
63 dest = create_new_pixbuf (src); |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
64 |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
65 has_alpha = gdk_pixbuf_get_has_alpha (src); |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
66 width = gdk_pixbuf_get_width (src); |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
67 height = gdk_pixbuf_get_height (src); |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
68 src_row_stride = gdk_pixbuf_get_rowstride (src); |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
69 dst_row_stride = gdk_pixbuf_get_rowstride (dest); |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
70 target_pixels = gdk_pixbuf_get_pixels (dest); |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
71 original_pixels = gdk_pixbuf_get_pixels (src); |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
72 |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
73 for (i = 0; i < height; i++) { |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
74 pixdest = target_pixels + i*dst_row_stride; |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
75 pixsrc = original_pixels + i*src_row_stride; |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
76 for (j = 0; j < width; j++) { |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
77 *pixdest++ = (*pixsrc++ * red_value) >> 8; |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
78 *pixdest++ = (*pixsrc++ * green_value) >> 8; |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
79 *pixdest++ = (*pixsrc++ * blue_value) >> 8; |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
80 if (has_alpha) { |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
81 *pixdest++ = *pixsrc++; |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
82 } |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
83 } |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
84 } |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
85 return dest; |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
86 } |
c108a98794b1
[svn] - add pixbuf_effects.c, containing various routines to alter images used by the skinengine
nenolod
parents:
diff
changeset
|
87 |