annotate src/pixbuf_util.c @ 967:eb5dbdff14f6

Move variable declaration at start of block.
author zas_
date Sun, 17 Aug 2008 09:00:33 +0000
parents f40509d56fe3
children 4fe8f9656107
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1 /*
196
f6e307c7bad6 rename GQview -> Geeqie over the code
nadvornik
parents: 95
diff changeset
2 * Geeqie
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3 * (C) 2004 John Ellis
475
48c8e49b571c updated copyright in source files
nadvornik
parents: 446
diff changeset
4 * Copyright (C) 2008 The Geeqie Team
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
5 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
6 * Author: John Ellis
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
7 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
8 * This software is released under the GNU General Public License (GNU GPL).
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
9 * Please read the included file COPYING for more information.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
10 * This software comes with no warranty of any kind, use at your own risk!
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
11 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
12
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
13
281
9995c5fb202a gqview.h -> main.h
zas_
parents: 198
diff changeset
14 #include "main.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
15 #include "pixbuf_util.h"
839
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
16 #include "exif.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
17
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
18 #include "icons/icons_inline.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
19
33
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
20 #include <math.h>
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
21
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
22
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
23 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
24 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
25 * png save
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
26 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
27 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
28
513
985fdfebd89e Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents: 475
diff changeset
29 gboolean pixbuf_to_file_as_png(GdkPixbuf *pixbuf, const char *filename)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
30 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
31 GError *error = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
32 gint ret;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
33
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
34 if (!pixbuf || !filename) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
35
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
36 ret = gdk_pixbuf_save(pixbuf, filename, "png", &error,
288
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 281
diff changeset
37 "tEXt::Software", GQ_APPNAME " " VERSION, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
38
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
39 if (error)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
40 {
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 513
diff changeset
41 log_printf("Error saving png file: %s\n", error->message);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
42 g_error_free(error);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
43 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
45 return ret;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
46 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
47
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
48 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
49 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
50 * jpeg save
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
51 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
52 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
53
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
54 gboolean pixbuf_to_file_as_jpg(GdkPixbuf *pixbuf, const gchar *filename, gint quality)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
55 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
56 GError *error = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
57 gchar *qbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
58 gboolean ret;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
59
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
60 if (!pixbuf || !filename) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
61
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
62 if (quality == -1) quality = 75;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
63 if (quality < 1 || quality > 100)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
64 {
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 513
diff changeset
65 log_printf("Jpeg not saved, invalid quality %d\n", quality);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
66 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
67 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
68
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
69 qbuf = g_strdup_printf("%d", quality);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
70 ret = gdk_pixbuf_save(pixbuf, filename, "jpeg", &error, "quality", qbuf, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
71 g_free(qbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
72
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
73 if (error)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74 {
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 513
diff changeset
75 log_printf("Error saving jpeg to %s\n%s\n", filename, error->message);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
76 g_error_free(error);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
77 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
78
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
79 return ret;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
80 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
81
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
82 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
83 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
84 * pixbuf from inline
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
85 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
86 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
87
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
88 typedef struct _PixbufInline PixbufInline;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
89 struct _PixbufInline
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
90 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
91 const gchar *key;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
92 const guint8 *data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
94
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
95 static PixbufInline inline_pixbuf_data[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
96 { PIXBUF_INLINE_FOLDER_CLOSED, folder_closed },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97 { PIXBUF_INLINE_FOLDER_LOCKED, folder_locked },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
98 { PIXBUF_INLINE_FOLDER_OPEN, folder_open },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
99 { PIXBUF_INLINE_FOLDER_UP, folder_up },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
100 { PIXBUF_INLINE_SCROLLER, icon_scroller },
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
101 { PIXBUF_INLINE_BROKEN, icon_broken },
91
d063f97503b7 Wed Nov 1 11:39:48 2006 John Ellis <johne@verizon.net>
gqview
parents: 82
diff changeset
102 { PIXBUF_INLINE_ICON, gqview_icon },
198
91563e0e88f2 changed logo
nadvornik
parents: 196
diff changeset
103 { PIXBUF_INLINE_LOGO, geeqie_logo },
41
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 33
diff changeset
104 { PIXBUF_INLINE_ICON_FLOAT, icon_float },
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 33
diff changeset
105 { PIXBUF_INLINE_ICON_THUMB, icon_thumb },
91
d063f97503b7 Wed Nov 1 11:39:48 2006 John Ellis <johne@verizon.net>
gqview
parents: 82
diff changeset
106 { PIXBUF_INLINE_ICON_BOOK, icon_book },
d063f97503b7 Wed Nov 1 11:39:48 2006 John Ellis <johne@verizon.net>
gqview
parents: 82
diff changeset
107 { PIXBUF_INLINE_ICON_CONFIG, icon_config },
d063f97503b7 Wed Nov 1 11:39:48 2006 John Ellis <johne@verizon.net>
gqview
parents: 82
diff changeset
108 { PIXBUF_INLINE_ICON_TOOLS, icon_tools },
d063f97503b7 Wed Nov 1 11:39:48 2006 John Ellis <johne@verizon.net>
gqview
parents: 82
diff changeset
109 { PIXBUF_INLINE_ICON_VIEW, icon_view },
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
110 { NULL, NULL }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
111 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
112
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
113 GdkPixbuf *pixbuf_inline(const gchar *key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
114 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
115 gint i;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
116
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
117 if (!key) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
118
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
119 i = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
120 while (inline_pixbuf_data[i].key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
121 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
122 if (strcmp(inline_pixbuf_data[i].key, key) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
123 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
124 return gdk_pixbuf_new_from_inline(-1, inline_pixbuf_data[i].data, FALSE, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
125 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
126 i++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
127 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
128
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 513
diff changeset
129 log_printf("warning: inline pixbuf key \"%s\" not found.\n", key);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
130
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
131 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
132 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
133
864
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
134 gint pixbuf_scale_aspect(gint req_w, gint req_h, gint old_w, gint old_h,
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
135 gint *new_w, gint *new_h)
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
136 {
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
137 if (((gdouble)req_w / old_w) < ((gdouble)req_h / old_h))
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
138 {
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
139 *new_w = req_w;
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
140 *new_h = (gdouble)*new_w / old_w * old_h;
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
141 if (*new_h < 1) *new_h = 1;
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
142 }
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
143 else
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
144 {
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
145 *new_h = req_h;
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
146 *new_w = (gdouble)*new_h / old_h * old_w;
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
147 if (*new_w < 1) *new_w = 1;
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
148 }
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
149
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
150 return (*new_w != old_w || *new_h != old_h);
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
151 }
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
152
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
153 GdkPixbuf *pixbuf_fallback(FileData *fd, gint requested_width, gint requested_height)
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
154 {
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
155 GdkPixbuf *pixbuf = pixbuf_inline(PIXBUF_INLINE_BROKEN); /* FIXME use different images according to FORMAT_CLASS */
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
156
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
157 if (requested_width && requested_height)
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
158 {
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
159 gint w = gdk_pixbuf_get_width(pixbuf);
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
160 gint h = gdk_pixbuf_get_height(pixbuf);
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
161
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
162 if (w > requested_width || h > requested_height)
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
163 {
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
164 gint nw, nh;
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
165
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
166 if (pixbuf_scale_aspect(requested_width, requested_height,
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
167 w, h, &nw, &nh))
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
168 {
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
169 GdkPixbuf *tmp;
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
170
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
171 tmp = pixbuf;
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
172 pixbuf = gdk_pixbuf_scale_simple(tmp, nw, nh, GDK_INTERP_TILES);
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
173 g_object_unref(G_OBJECT(tmp));
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
174 }
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
175 }
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
176 }
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
177 return pixbuf;
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
178 }
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
179
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 839
diff changeset
180
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
181 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
182 *-----------------------------------------------------------------------------
33
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
183 * misc utils
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
184 *-----------------------------------------------------------------------------
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
185 */
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
186
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
187 gint util_clip_region(gint x, gint y, gint w, gint h,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
188 gint clip_x, gint clip_y, gint clip_w, gint clip_h,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
189 gint *rx, gint *ry, gint *rw, gint *rh)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
190 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
191 if (clip_x + clip_w <= x ||
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
192 clip_x >= x + w ||
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
193 clip_y + clip_h <= y ||
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
194 clip_y >= y + h)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
195 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
196 return FALSE;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
197 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
198
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
199 *rx = MAX(x, clip_x);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
200 *rw = MIN((x + w), (clip_x + clip_w)) - *rx;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
201
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
202 *ry = MAX(y, clip_y);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
203 *rh = MIN((y + h), (clip_y + clip_h)) - *ry;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
204
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
205 return TRUE;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
206 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
207
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
208 /*
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
209 *-----------------------------------------------------------------------------
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
210 * pixbuf rotation
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
211 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
212 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
213
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
214 static void pixbuf_copy_block_rotate(guchar *src, gint src_row_stride, gint x, gint y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
215 guchar *dest, gint dest_row_stride, gint w, gint h,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
216 gint bytes_per_pixel, gint counter_clockwise)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
217 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
218 gint i, j;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
219 guchar *sp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
220 guchar *dp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
221
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
222 for (i = 0; i < h; i++)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
223 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
224 sp = src + ((i + y) * src_row_stride) + (x * bytes_per_pixel);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
225 for (j = 0; j < w; j++)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
226 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
227 if (counter_clockwise)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
228 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
229 dp = dest + ((w - j - 1) * dest_row_stride) + (i * bytes_per_pixel);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
230 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
231 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
232 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
233 dp = dest + (j * dest_row_stride) + ((h - i - 1) * bytes_per_pixel);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
234 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
235 *(dp++) = *(sp++); /* r */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
236 *(dp++) = *(sp++); /* g */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
237 *(dp++) = *(sp++); /* b */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
238 if (bytes_per_pixel == 4) *(dp) = *(sp++); /* a */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
240 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 288
diff changeset
241
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
242 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
243
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244 static void pixbuf_copy_block(guchar *src, gint src_row_stride, gint w, gint h,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
245 guchar *dest, gint dest_row_stride, gint x, gint y, gint bytes_per_pixel)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
246 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
247 gint i;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
248 guchar *sp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
249 guchar *dp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
250
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
251 for (i = 0; i < h; i++)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
252 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
253 sp = src + (i * src_row_stride);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
254 dp = dest + ((y + i) * dest_row_stride) + (x * bytes_per_pixel);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
255 memcpy(dp, sp, w * bytes_per_pixel);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
256 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
257 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
258
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
259 #define ROTATE_BUFFER_WIDTH 48
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
260 #define ROTATE_BUFFER_HEIGHT 48
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
261
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
262 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
263 * Returns a copy of pixbuf src rotated 90 degrees clockwise or 90 counterclockwise
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
264 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
265 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
266 GdkPixbuf *pixbuf_copy_rotate_90(GdkPixbuf *src, gint counter_clockwise)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
267 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
268 GdkPixbuf *dest;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
269 gint has_alpha;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
270 gint sw, sh, srs;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
271 gint dw, dh, drs;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
272 guchar *s_pix;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 288
diff changeset
273 guchar *d_pix;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
274 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
275 guchar *sp;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 288
diff changeset
276 guchar *dp;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
277 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
278 gint i, j;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
279 gint a;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
280 GdkPixbuf *buffer;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 288
diff changeset
281 guchar *b_pix;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
282 gint brs;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
283 gint w, h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
284
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
285 if (!src) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
286
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
287 sw = gdk_pixbuf_get_width(src);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
288 sh = gdk_pixbuf_get_height(src);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
289 has_alpha = gdk_pixbuf_get_has_alpha(src);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
290 srs = gdk_pixbuf_get_rowstride(src);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
291 s_pix = gdk_pixbuf_get_pixels(src);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
292
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
293 dw = sh;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
294 dh = sw;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
295 dest = gdk_pixbuf_new(GDK_COLORSPACE_RGB, has_alpha, 8, dw, dh);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
296 drs = gdk_pixbuf_get_rowstride(dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
297 d_pix = gdk_pixbuf_get_pixels(dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
298
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
299 a = (has_alpha ? 4 : 3);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
300
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
301 buffer = gdk_pixbuf_new(GDK_COLORSPACE_RGB, has_alpha, 8,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
302 ROTATE_BUFFER_WIDTH, ROTATE_BUFFER_HEIGHT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
303 b_pix = gdk_pixbuf_get_pixels(buffer);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
304 brs = gdk_pixbuf_get_rowstride(buffer);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
305
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
306 for (i = 0; i < sh; i+= ROTATE_BUFFER_WIDTH)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
307 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
308 w = MIN(ROTATE_BUFFER_WIDTH, (sh - i));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
309 for (j = 0; j < sw; j += ROTATE_BUFFER_HEIGHT)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
310 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
311 gint x, y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
312
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
313 h = MIN(ROTATE_BUFFER_HEIGHT, (sw - j));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
314 pixbuf_copy_block_rotate(s_pix, srs, j, i,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
315 b_pix, brs, h, w,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
316 a, counter_clockwise);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
317
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
318 if (counter_clockwise)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
319 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
320 x = i;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
321 y = sw - h - j;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
322 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
323 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
324 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
325 x = sh - w - i;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
326 y = j;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
327 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
328 pixbuf_copy_block(b_pix, brs, w, h,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
329 d_pix, drs, x, y, a);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
330 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
331 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
332
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
333 gdk_pixbuf_unref(buffer);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
334
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
335 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
336 /* this is the simple version of rotation (roughly 2-4x slower) */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
337
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
338 for (i = 0; i < sh; i++)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
339 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
340 sp = s_pix + (i * srs);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
341 for (j = 0; j < sw; j++)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
342 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
343 if (counter_clockwise)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
344 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
345 dp = d_pix + ((dh - j - 1) * drs) + (i * a);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
346 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
347 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
348 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
349 dp = d_pix + (j * drs) + ((dw - i - 1) * a);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
350 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
351
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
352 *(dp++) = *(sp++); /* r */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
353 *(dp++) = *(sp++); /* g */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
354 *(dp++) = *(sp++); /* b */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
355 if (has_alpha) *(dp) = *(sp++); /* a */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
356 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
357 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
358 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
359
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
360 return dest;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
361 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
362
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
363 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
364 * Returns a copy of pixbuf mirrored and or flipped.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
365 * TO do a 180 degree rotations set both mirror and flipped TRUE
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
366 * if mirror and flip are FALSE, result is a simple copy.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
367 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
368 GdkPixbuf *pixbuf_copy_mirror(GdkPixbuf *src, gint mirror, gint flip)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
369 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
370 GdkPixbuf *dest;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
371 gint has_alpha;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
372 gint w, h, srs;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
373 gint drs;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
374 guchar *s_pix;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 288
diff changeset
375 guchar *d_pix;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
376 guchar *sp;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 288
diff changeset
377 guchar *dp;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
378 gint i, j;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
379 gint a;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
380
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
381 if (!src) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
382
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
383 w = gdk_pixbuf_get_width(src);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
384 h = gdk_pixbuf_get_height(src);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
385 has_alpha = gdk_pixbuf_get_has_alpha(src);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
386 srs = gdk_pixbuf_get_rowstride(src);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
387 s_pix = gdk_pixbuf_get_pixels(src);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
388
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
389 dest = gdk_pixbuf_new(GDK_COLORSPACE_RGB, has_alpha, 8, w, h);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
390 drs = gdk_pixbuf_get_rowstride(dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
391 d_pix = gdk_pixbuf_get_pixels(dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
392
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
393 a = has_alpha ? 4 : 3;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
394
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
395 for (i = 0; i < h; i++)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
396 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
397 sp = s_pix + (i * srs);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
398 if (flip)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
399 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
400 dp = d_pix + ((h - i - 1) * drs);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
401 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
402 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
403 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
404 dp = d_pix + (i * drs);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
405 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
406 if (mirror)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
407 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
408 dp += (w - 1) * a;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
409 for (j = 0; j < w; j++)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
410 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
411 *(dp++) = *(sp++); /* r */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
412 *(dp++) = *(sp++); /* g */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413 *(dp++) = *(sp++); /* b */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414 if (has_alpha) *(dp) = *(sp++); /* a */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
415 dp -= (a + 3);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
416 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
417 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
418 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
419 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
420 for (j = 0; j < w; j++)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
421 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
422 *(dp++) = *(sp++); /* r */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
423 *(dp++) = *(sp++); /* g */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
424 *(dp++) = *(sp++); /* b */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
425 if (has_alpha) *(dp++) = *(sp++); /* a */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
426 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
427 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
428 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
429
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
430 return dest;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
431 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
432
839
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
433 GdkPixbuf* pixbuf_apply_orientation(GdkPixbuf *pixbuf, gint orientation)
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
434 {
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
435 GdkPixbuf *dest;
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
436 GdkPixbuf *tmp = NULL;
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
437
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
438 switch (orientation)
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
439 {
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
440 case EXIF_ORIENTATION_TOP_LEFT:
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
441 dest = gdk_pixbuf_copy(pixbuf);
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
442 break;
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
443 case EXIF_ORIENTATION_TOP_RIGHT:
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
444 /* mirrored */
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
445 dest = pixbuf_copy_mirror(pixbuf, TRUE, FALSE);
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
446 break;
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
447 case EXIF_ORIENTATION_BOTTOM_RIGHT:
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
448 /* upside down */
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
449 dest = pixbuf_copy_mirror(pixbuf, TRUE, TRUE);
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
450 break;
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
451 case EXIF_ORIENTATION_BOTTOM_LEFT:
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
452 /* flipped */
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
453 dest = pixbuf_copy_mirror(pixbuf, FALSE, TRUE);
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
454 break;
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
455 case EXIF_ORIENTATION_LEFT_TOP:
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
456 tmp = pixbuf_copy_mirror(pixbuf, FALSE, TRUE);
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
457 dest = pixbuf_copy_rotate_90(tmp, FALSE);
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
458 break;
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
459 case EXIF_ORIENTATION_RIGHT_TOP:
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
460 /* rotated -90 (270) */
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
461 dest = pixbuf_copy_rotate_90(pixbuf, FALSE);
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
462 break;
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
463 case EXIF_ORIENTATION_RIGHT_BOTTOM:
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
464 tmp = pixbuf_copy_mirror(pixbuf, FALSE, TRUE);
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
465 dest = pixbuf_copy_rotate_90(tmp, TRUE);
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
466 break;
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
467 case EXIF_ORIENTATION_LEFT_BOTTOM:
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
468 /* rotated 90 */
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
469 dest = pixbuf_copy_rotate_90(pixbuf, TRUE);
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
470 break;
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
471 default:
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
472 dest = gdk_pixbuf_copy(pixbuf);
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
473 break;
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
474 }
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
475 if (tmp) gdk_pixbuf_unref(tmp);
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
476 return dest;
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
477
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
478 }
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 673
diff changeset
479
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
480
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
481 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
482 *-----------------------------------------------------------------------------
33
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
483 * pixbuf drawing (rectangles)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
484 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
485 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
486
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
487 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
488 * Fills region of pixbuf at x,y over w,h
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
489 * with colors red (r), green (g), blue (b)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
490 * applying alpha (a), use a=255 for solid.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
491 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
492 void pixbuf_draw_rect_fill(GdkPixbuf *pb,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
493 gint x, gint y, gint w, gint h,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
494 gint r, gint g, gint b, gint a)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
495 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
496 gint p_alpha;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
497 gint pw, ph, prs;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
498 guchar *p_pix;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
499 guchar *pp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
500 gint i, j;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
501
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
502 if (!pb) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
503
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
504 pw = gdk_pixbuf_get_width(pb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
505 ph = gdk_pixbuf_get_height(pb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
506
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
507 if (x < 0 || x + w > pw) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
508 if (y < 0 || y + h > ph) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
509
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
510 p_alpha = gdk_pixbuf_get_has_alpha(pb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
511 prs = gdk_pixbuf_get_rowstride(pb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
512 p_pix = gdk_pixbuf_get_pixels(pb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
513
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 288
diff changeset
514 for (i = 0; i < h; i++)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
515 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
516 pp = p_pix + (y + i) * prs + (x * (p_alpha ? 4 : 3));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
517 for (j = 0; j < w; j++)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
518 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
519 *pp = (r * a + *pp * (256-a)) >> 8;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
520 pp++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
521 *pp = (g * a + *pp * (256-a)) >> 8;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
522 pp++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
523 *pp = (b * a + *pp * (256-a)) >> 8;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
524 pp++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
525 if (p_alpha) pp++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
526 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
527 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
528 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
529
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
530 void pixbuf_draw_rect(GdkPixbuf *pb,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
531 gint x, gint y, gint w, gint h,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
532 gint r, gint g, gint b, gint a,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
533 gint left, gint right, gint top, gint bottom)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
534 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
535 pixbuf_draw_rect_fill(pb, x + left, y, w - left - right, top,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
536 r, g, b ,a);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
537 pixbuf_draw_rect_fill(pb, x + w - right, y, right, h,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
538 r, g, b ,a);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
539 pixbuf_draw_rect_fill(pb, x + left, y + h - bottom, w - left - right, bottom,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
540 r, g, b ,a);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
541 pixbuf_draw_rect_fill(pb, x, y, left, h,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
542 r, g, b ,a);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
543 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
544
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
545 void pixbuf_set_rect_fill(GdkPixbuf *pb,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
546 gint x, gint y, gint w, gint h,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
547 gint r, gint g, gint b, gint a)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
548 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
549 gint p_alpha;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
550 gint pw, ph, prs;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
551 guchar *p_pix;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
552 guchar *pp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
553 gint i, j;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
554
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
555 if (!pb) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
556
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
557 pw = gdk_pixbuf_get_width(pb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
558 ph = gdk_pixbuf_get_height(pb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
559
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
560 if (x < 0 || x + w > pw) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
561 if (y < 0 || y + h > ph) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
562
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
563 p_alpha = gdk_pixbuf_get_has_alpha(pb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
564 prs = gdk_pixbuf_get_rowstride(pb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
565 p_pix = gdk_pixbuf_get_pixels(pb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
566
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 288
diff changeset
567 for (i = 0; i < h; i++)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
568 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
569 pp = p_pix + (y + i) * prs + (x * (p_alpha ? 4 : 3));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
570 for (j = 0; j < w; j++)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
571 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
572 *pp = r; pp++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
573 *pp = g; pp++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
574 *pp = b; pp++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
575 if (p_alpha) { *pp = a; pp++; }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
576 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
577 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
578 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
579
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
580 void pixbuf_set_rect(GdkPixbuf *pb,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
581 gint x, gint y, gint w, gint h,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
582 gint r, gint g, gint b, gint a,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
583 gint left, gint right, gint top, gint bottom)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
584 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
585 pixbuf_set_rect_fill(pb, x + left, y, w - left - right, top,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
586 r, g, b ,a);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
587 pixbuf_set_rect_fill(pb, x + w - right, y, right, h,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
588 r, g, b ,a);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
589 pixbuf_set_rect_fill(pb, x + left, y + h - bottom, w - left - right, bottom,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
590 r, g, b ,a);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
591 pixbuf_set_rect_fill(pb, x, y, left, h,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
592 r, g, b ,a);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
593 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
594
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
595 void pixbuf_pixel_set(GdkPixbuf *pb, gint x, gint y, gint r, gint g, gint b, gint a)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
596 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
597 guchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
598 gint has_alpha;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
599 gint rowstride;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
600 guchar *p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
601
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
602 if (x < 0 || x >= gdk_pixbuf_get_width(pb) ||
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 288
diff changeset
603 y < 0 || y >= gdk_pixbuf_get_height(pb)) return;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
604
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
605 buf = gdk_pixbuf_get_pixels(pb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
606 has_alpha = gdk_pixbuf_get_has_alpha(pb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
607 rowstride = gdk_pixbuf_get_rowstride(pb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
608
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 288
diff changeset
609 p = buf + (y * rowstride) + (x * (has_alpha ? 4 : 3));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
610 *p = r; p++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
611 *p = g; p++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
612 *p = b; p++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
613 if (has_alpha) *p = a;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
614 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
615
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
616
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
617 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
618 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
619 * pixbuf text rendering
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
620 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
621 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
622
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
623 static void pixbuf_copy_font(GdkPixbuf *src, gint sx, gint sy,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
624 GdkPixbuf *dest, gint dx, gint dy,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
625 gint w, gint h,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
626 guint8 r, guint8 g, guint8 b, guint8 a)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
627 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
628 gint sw, sh, srs;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
629 gint s_alpha;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
630 gint s_step;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
631 guchar *s_pix;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
632 gint dw, dh, drs;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
633 gint d_alpha;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
634 gint d_step;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
635 guchar *d_pix;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
636
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
637 guchar *sp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
638 guchar *dp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
639 gint i, j;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
640
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
641 if (!src || !dest) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
642
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
643 sw = gdk_pixbuf_get_width(src);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
644 sh = gdk_pixbuf_get_height(src);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
645
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
646 if (sx < 0 || sx + w > sw) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
647 if (sy < 0 || sy + h > sh) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
648
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
649 dw = gdk_pixbuf_get_width(dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
650 dh = gdk_pixbuf_get_height(dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
651
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
652 if (dx < 0 || dx + w > dw) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
653 if (dy < 0 || dy + h > dh) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
654
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
655 s_alpha = gdk_pixbuf_get_has_alpha(src);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
656 d_alpha = gdk_pixbuf_get_has_alpha(dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
657 srs = gdk_pixbuf_get_rowstride(src);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
658 drs = gdk_pixbuf_get_rowstride(dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
659 s_pix = gdk_pixbuf_get_pixels(src);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
660 d_pix = gdk_pixbuf_get_pixels(dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
661
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
662 s_step = (s_alpha) ? 4 : 3;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
663 d_step = (d_alpha) ? 4 : 3;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
664
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
665 for (i = 0; i < h; i++)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
666 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
667 sp = s_pix + (sy + i) * srs + sx * s_step;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
668 dp = d_pix + (dy + i) * drs + dx * d_step;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
669 for (j = 0; j < w; j++)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
670 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
671 if (*sp)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
672 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
673 guint8 asub;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
674
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
675 asub = a * sp[0] / 255;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
676 *dp = (r * asub + *dp * (256-asub)) >> 8;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
677 dp++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
678 asub = a * sp[1] / 255;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
679 *dp = (g * asub + *dp * (256-asub)) >> 8;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
680 dp++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
681 asub = a * sp[2] / 255;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
682 *dp = (b * asub + *dp * (256-asub)) >> 8;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
683 dp++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
684
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
685 if (d_alpha)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
686 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
687 *dp = MAX(*dp, a * ((sp[0] + sp[1] + sp[2]) / 3) / 255);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
688 dp++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
689 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
690 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
691 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
692 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
693 dp += d_step;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
694 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
695
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
696 sp += s_step;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
697 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
698 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
699 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
700
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
701 void pixbuf_draw_layout(GdkPixbuf *pixbuf, PangoLayout *layout, GtkWidget *widget,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
702 gint x, gint y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
703 guint8 r, guint8 g, guint8 b, guint8 a)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
704 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
705 GdkPixmap *pixmap;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
706 GdkPixbuf *buffer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
707 gint w, h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
708 GdkGC *gc;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
709 gint sx, sy;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
710 gint dw, dh;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
711
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
712 if (!widget || !widget->window) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
713
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
714 pango_layout_get_pixel_size(layout, &w, &h);
95
eb9bb29cbd65 Fri Nov 3 11:40:48 2006 John Ellis <johne@verizon.net>
gqview
parents: 91
diff changeset
715 if (w < 1 || h < 1) return;
eb9bb29cbd65 Fri Nov 3 11:40:48 2006 John Ellis <johne@verizon.net>
gqview
parents: 91
diff changeset
716
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
717 pixmap = gdk_pixmap_new(widget->window, w, h, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
718
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
719 gc = gdk_gc_new(widget->window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
720 gdk_gc_copy(gc, widget->style->black_gc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
721 gdk_draw_rectangle(pixmap, gc, TRUE, 0, 0, w, h);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
722 gdk_gc_copy(gc, widget->style->white_gc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
723 gdk_draw_layout(pixmap, gc, 0, 0, layout);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
724 g_object_unref(gc);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
725
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
726 buffer = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, w, h);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
727 gdk_pixbuf_get_from_drawable(buffer, pixmap,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
728 gdk_drawable_get_colormap(widget->window),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
729 0, 0, 0, 0, w, h);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
730 g_object_unref(pixmap);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
731
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
732 sx = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
733 sy = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
734 dw = gdk_pixbuf_get_width(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
735 dh = gdk_pixbuf_get_height(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
736
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
737 if (x < 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
738 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
739 w += x;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
740 sx = -x;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
741 x = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
742 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
743
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
744 if (y < 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
745 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
746 h += y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
747 sy = -y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
748 y = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
749 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
750
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
751 if (x + w > dw) w = dw - x;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
752 if (y + h > dh) h = dh - y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
753
12
147f4c4b9025 ##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents: 9
diff changeset
754 pixbuf_copy_font(buffer, sx, sy,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
755 pixbuf, x, y, w, h,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
756 r, g, b, a);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
757
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
758 g_object_unref(buffer);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
759 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
760
33
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
761 /*
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
762 *-----------------------------------------------------------------------------
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
763 * pixbuf drawing (triangle)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
764 *-----------------------------------------------------------------------------
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
765 */
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
766
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
767 void util_clip_triangle(gint x1, gint y1, gint x2, gint y2, gint x3, gint y3,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
768 gint *rx, gint *ry, gint *rw, gint *rh)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
769 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
770 gint tx, ty, tw, th;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
771
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
772 tx = MIN(x1, x2);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
773 tx = MIN(tx, x3);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
774 ty = MIN(y1, y2);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
775 ty = MIN(ty, y3);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
776 tw = MAX(abs(x1 - x2), abs(x2 - x3));
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
777 tw = MAX(tw, abs(x3 - x1));
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
778 th = MAX(abs(y1 - y2), abs(y2 - y3));
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
779 th = MAX(th, abs(y3 - y1));
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
780
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
781 *rx = tx;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
782 *ry = ty;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
783 *rw = tw;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
784 *rh = th;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
785 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
786
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
787 void pixbuf_draw_triangle(GdkPixbuf *pb,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
788 gint clip_x, gint clip_y, gint clip_w, gint clip_h,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
789 gint x1, gint y1, gint x2, gint y2, gint x3, gint y3,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
790 guint8 r, guint8 g, guint8 b, guint8 a)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
791 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
792 gint p_alpha;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
793 gint pw, ph, prs;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
794 gint rx, ry, rw, rh;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
795 gint tx, ty, tw, th;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
796 gint fx1, fy1;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
797 gint fx2, fy2;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
798 gint fw, fh;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
799 guchar *p_pix;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
800 guchar *pp;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
801 gint p_step;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
802 gdouble slope1, slope2;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
803 gint slope1_x, slope1_y;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
804 gint y;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
805 gint t;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
806 gint middle = FALSE;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
807
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
808 if (!pb) return;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
809
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
810 pw = gdk_pixbuf_get_width(pb);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
811 ph = gdk_pixbuf_get_height(pb);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
812
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
813 if (!util_clip_region(0, 0, pw, ph,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
814 clip_x, clip_y, clip_w, clip_h,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
815 &rx, &ry, &rw, &rh)) return;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
816
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
817 util_clip_triangle(x1, y1, x2, y2, x3, y3,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
818 &tx, &ty, &tw, &th);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
819
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
820 if (!util_clip_region(rx, ry, rw, rh,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
821 tx, ty, tw, th,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
822 &fx1, &fy1, &fw, &fh)) return;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
823 fx2 = fx1 + fw;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
824 fy2 = fy1 + fh;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
825
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
826 p_alpha = gdk_pixbuf_get_has_alpha(pb);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
827 prs = gdk_pixbuf_get_rowstride(pb);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
828 p_pix = gdk_pixbuf_get_pixels(pb);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
829
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
830 p_step = (p_alpha) ? 4 : 3;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
831
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
832 if (y1 > y2)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
833 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
834 t = x1; x1 = x2; x2 = t;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
835 t = y1; y1 = y2; y2 = t;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
836 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
837 if (y2 > y3)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
838 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
839 t = x2; x2 = x3; x3 = t;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
840 t = y2; y2 = y3; y3 = t;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
841 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
842 if (y1 > y2)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
843 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
844 t = x1; x1 = x2; x2 = t;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
845 t = y1; y1 = y2; y2 = t;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
846 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
847
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
848 slope1 = (gdouble)(y2 - y1);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
849 if (slope1) slope1 = (gdouble)(x2 - x1) / slope1;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
850 slope1_x = x1;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
851 slope1_y = y1;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
852 slope2 = (gdouble)(y3 - y1);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
853 if (slope2) slope2 = (gdouble)(x3 - x1) / slope2;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
854
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
855 for (y = fy1; y < fy2; y++)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
856 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
857 gint xa, xb;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
858
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
859 if (!middle && y > y2)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
860 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
861 slope1 = (gdouble)(y3 - y2);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
862 if (slope1) slope1 = (gdouble)(x3 - x2) / slope1;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
863 slope1_x = x2;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
864 slope1_y = y2;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
865
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
866 middle = TRUE;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
867 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
868
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
869 xa = slope1_x + ((gdouble)slope1 * (y - slope1_y) + 0.5);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
870 xb = x1 + ((gdouble)slope2 * (y - y1) + 0.5);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
871
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
872 if (xa > xb)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
873 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
874 t = xa; xa = xb; xb = t;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
875 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
876
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
877 xa = CLAMP(xa, fx1, fx2);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
878 xb = CLAMP(xb, fx1, fx2);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
879
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
880 pp = p_pix + y * prs + xa * p_step;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
881
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
882 while (xa < xb)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
883 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
884 *pp = (r * a + *pp * (256-a)) >> 8;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
885 pp++;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
886 *pp = (g * a + *pp * (256-a)) >> 8;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
887 pp++;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
888 *pp = (b * a + *pp * (256-a)) >> 8;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
889 pp++;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
890 if (p_alpha) pp++;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
891
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
892 xa++;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
893 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
894 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
895 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
896
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
897 /*
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
898 *-----------------------------------------------------------------------------
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
899 * pixbuf drawing (line)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
900 *-----------------------------------------------------------------------------
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
901 */
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
902
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
903 static gint util_clip_line(gdouble clip_x, gdouble clip_y, gdouble clip_w, gdouble clip_h,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
904 gdouble x1, gdouble y1, gdouble x2, gdouble y2,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
905 gdouble *rx1, gdouble *ry1, gdouble *rx2, gdouble *ry2)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
906 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
907 gint flip = FALSE;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
908 gdouble d;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
909
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
910 if (x1 > x2)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
911 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
912 gdouble t;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
913
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
914 t = x1; x1 = x2; x2 = t;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
915 t = y1; y1 = y2; y2 = t;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
916 flip = TRUE;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
917 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
918
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
919 if (x2 < clip_x || x1 > clip_x + clip_w) return FALSE;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
920
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
921 if (y1 < y2)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
922 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
923 if (y2 < clip_y || y1 > clip_y + clip_h) return FALSE;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
924 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
925 else
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
926 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
927 if (y1 < clip_y || y2 > clip_y + clip_h) return FALSE;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
928 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
929
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
930 #if 0
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
931 if (x1 >= clip_x && x2 <= clip_x + clip_w)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
932 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
933 if (y1 < y2)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
934 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
935 if (y1 >= clip_y && y2 <= clip_y + clip_h) return TRUE;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
936 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
937 else
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
938 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
939 if (y2 >= clip_y && y1 <= clip_y + clip_h) return TRUE;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
940 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
941 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
942 #endif
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
943
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
944 d = x2 - x1;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
945 if (d > 0.0)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
946 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
947 gdouble slope;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
948
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
949 slope = (y2 - y1) / d;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
950 if (x1 < clip_x)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
951 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
952 y1 = y1 + slope * (clip_x - x1);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
953 x1 = clip_x;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
954 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
955 if (x2 > clip_x + clip_w)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
956 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
957 y2 = y2 + slope * (clip_x + clip_w - x2);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
958 x2 = clip_x + clip_w;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
959 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
960 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
961
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
962 if (y1 < y2)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
963 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
964 if (y2 < clip_y || y1 > clip_y + clip_h) return FALSE;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
965 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
966 else
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
967 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
968 gdouble t;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
969
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
970 if (y1 < clip_y || y2 > clip_y + clip_h) return FALSE;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
971
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
972 t = x1; x1 = x2; x2 = t;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
973 t = y1; y1 = y2; y2 = t;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
974 flip = !flip;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
975 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
976
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
977 d = y2 - y1;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
978 if (d > 0.0)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
979 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
980 gdouble slope;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
981
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
982 slope = (x2 - x1) / d;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
983 if (y1 < clip_y)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
984 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
985 x1 = x1 + slope * (clip_y - y1);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
986 y1 = clip_y;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
987 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
988 if (y2 > clip_y + clip_h)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
989 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
990 x2 = x2 + slope * (clip_y + clip_h - y2);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
991 y2 = clip_y + clip_h;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
992 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
993 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
994
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
995 if (flip)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
996 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
997 *rx1 = x2;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
998 *ry1 = y2;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
999 *rx2 = x1;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1000 *ry2 = y1;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1001 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1002 else
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1003 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1004 *rx1 = x1;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1005 *ry1 = y1;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1006 *rx2 = x2;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1007 *ry2 = y2;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1008 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1009
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1010 return TRUE;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1011 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1012
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1013 void pixbuf_draw_line(GdkPixbuf *pb,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1014 gint clip_x, gint clip_y, gint clip_w, gint clip_h,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1015 gint x1, gint y1, gint x2, gint y2,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1016 guint8 r, guint8 g, guint8 b, guint8 a)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1017 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1018 gint p_alpha;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1019 gint pw, ph, prs;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1020 gint rx, ry, rw, rh;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1021 gdouble rx1, ry1, rx2, ry2;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1022 guchar *p_pix;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1023 guchar *pp;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1024 gint p_step;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1025 gdouble slope;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1026 gdouble x, y;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1027 gint px, py;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1028 gint cx1, cy1, cx2, cy2;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1029
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1030 if (!pb) return;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1031
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1032 pw = gdk_pixbuf_get_width(pb);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1033 ph = gdk_pixbuf_get_height(pb);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1034
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1035 if (!util_clip_region(0, 0, pw, ph,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1036 clip_x, clip_y, clip_w, clip_h,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1037 &rx, &ry, &rw, &rh)) return;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1038 if (!util_clip_line((gdouble)rx, (gdouble)ry, (gdouble)rw, (gdouble)rh,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1039 (gdouble)x1, (gdouble)y1, (gdouble)x2, (gdouble)y2,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1040 &rx1, &ry1, &rx2, &ry2)) return;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1041
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1042 cx1 = rx;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1043 cy1 = ry;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1044 cx2 = rx + rw;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1045 cy2 = ry + rh;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1046
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1047 p_alpha = gdk_pixbuf_get_has_alpha(pb);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1048 prs = gdk_pixbuf_get_rowstride(pb);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1049 p_pix = gdk_pixbuf_get_pixels(pb);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1050
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1051 p_step = (p_alpha) ? 4 : 3;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1052
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1053 if (fabs(rx2 - rx1) > fabs(ry2 - ry1))
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1054 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1055 if (rx1 > rx2)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1056 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1057 gdouble t;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1058 t = rx1; rx1 = rx2; rx2 = t;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1059 t = ry1; ry1 = ry2; ry2 = t;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1060 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1061
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1062 slope = rx2 - rx1;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1063 if (slope != 0.0) slope = (ry2 - ry1) / slope;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1064 for (x = rx1; x < rx2; x += 1.0)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1065 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1066 px = (gint)(x + 0.5);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1067 py = (gint)(ry1 + (x - rx1) * slope + 0.5);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1068
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1069 if (px >= cx1 && px < cx2 && py >= cy1 && py < cy2)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1070 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1071 pp = p_pix + py * prs + px * p_step;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1072 *pp = (r * a + *pp * (256-a)) >> 8;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1073 pp++;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1074 *pp = (g * a + *pp * (256-a)) >> 8;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1075 pp++;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1076 *pp = (b * a + *pp * (256-a)) >> 8;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1077 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1078 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1079 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1080 else
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1081 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1082 if (ry1 > ry2)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1083 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1084 gdouble t;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1085 t = rx1; rx1 = rx2; rx2 = t;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1086 t = ry1; ry1 = ry2; ry2 = t;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1087 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1088
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1089 slope = ry2 - ry1;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1090 if (slope != 0.0) slope = (rx2 - rx1) / slope;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1091 for (y = ry1; y < ry2; y += 1.0)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1092 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1093 px = (gint)(rx1 + (y - ry1) * slope + 0.5);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1094 py = (gint)(y + 0.5);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1095
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1096 if (px >= cx1 && px < cx2 && py >= cy1 && py < cy2)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1097 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1098 pp = p_pix + py * prs + px * p_step;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1099 *pp = (r * a + *pp * (256-a)) >> 8;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1100 pp++;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1101 *pp = (g * a + *pp * (256-a)) >> 8;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1102 pp++;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1103 *pp = (b * a + *pp * (256-a)) >> 8;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1104 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1105 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1106 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1107 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1108
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1109 /*
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1110 *-----------------------------------------------------------------------------
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1111 * pixbuf drawing (fades and shadows)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1112 *-----------------------------------------------------------------------------
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1113 */
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1114
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1115 static void pixbuf_draw_fade_linear(guchar *p_pix, gint prs, gint p_alpha,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1116 gint s, gint vertical, gint border,
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 288
diff changeset
1117 gint x1, gint y1, gint x2, gint y2,
33
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1118 guint8 r, guint8 g, guint8 b, guint8 a)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1119 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1120 guchar *pp;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1121 gint p_step;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1122 guint8 n = a;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1123 gint i, j;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1124
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1125 p_step = (p_alpha) ? 4 : 3;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1126 for (j = y1; j < y2; j++)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1127 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1128 pp = p_pix + j * prs + x1 * p_step;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1129 if (!vertical) n = a - a * abs(j - s) / border;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1130 for (i = x1; i < x2; i++)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1131 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1132 if (vertical) n = a - a * abs(i - s) / border;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1133 *pp = (r * n + *pp * (256-n)) >> 8;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1134 pp++;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1135 *pp = (g * n + *pp * (256-n)) >> 8;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1136 pp++;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1137 *pp = (b * n + *pp * (256-n)) >> 8;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1138 pp++;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1139 if (p_alpha) pp++;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1140 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1141 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1142 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1143
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1144 static void pixbuf_draw_fade_radius(guchar *p_pix, gint prs, gint p_alpha,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1145 gint sx, gint sy, gint border,
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 288
diff changeset
1146 gint x1, gint y1, gint x2, gint y2,
33
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1147 guint8 r, guint8 g, guint8 b, guint8 a)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1148 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1149 guchar *pp;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1150 gint p_step;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1151 gint i, j;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1152
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1153 p_step = (p_alpha) ? 4 : 3;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1154 for (j = y1; j < y2; j++)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1155 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1156 pp = p_pix + j * prs + x1 * p_step;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1157 for (i = x1; i < x2; i++)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1158 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1159 guint8 n;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1160 gint r;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1161
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1162 r = MIN(border, (gint)sqrt((i-sx)*(i-sx) + (j-sy)*(j-sy)));
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1163 n = a - a * r / border;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1164 *pp = (r * n + *pp * (256-n)) >> 8;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1165 pp++;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1166 *pp = (g * n + *pp * (256-n)) >> 8;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1167 pp++;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1168 *pp = (b * n + *pp * (256-n)) >> 8;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1169 pp++;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1170 if (p_alpha) pp++;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1171 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1172 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1173 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1174
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1175 void pixbuf_draw_shadow(GdkPixbuf *pb,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1176 gint clip_x, gint clip_y, gint clip_w, gint clip_h,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1177 gint x, gint y, gint w, gint h, gint border,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1178 guint8 r, guint8 g, guint8 b, guint8 a)
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1179 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1180 gint p_alpha;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1181 gint pw, ph, prs;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1182 gint rx, ry, rw, rh;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1183 gint fx, fy, fw, fh;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1184 guchar *p_pix;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1185
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1186 if (!pb) return;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1187
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1188 pw = gdk_pixbuf_get_width(pb);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1189 ph = gdk_pixbuf_get_height(pb);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1190
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1191 if (!util_clip_region(0, 0, pw, ph,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1192 clip_x, clip_y, clip_w, clip_h,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1193 &rx, &ry, &rw, &rh)) return;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1194
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1195 p_alpha = gdk_pixbuf_get_has_alpha(pb);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1196 prs = gdk_pixbuf_get_rowstride(pb);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1197 p_pix = gdk_pixbuf_get_pixels(pb);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1198
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1199 if (util_clip_region(x + border, y + border, w - border * 2, h - border * 2,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1200 rx, ry, rw, rh,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1201 &fx, &fy, &fw, &fh))
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1202 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1203 pixbuf_draw_rect_fill(pb, fx, fy, fw, fh, r, g, b, a);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1204 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1205
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1206 if (border < 1) return;
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1207
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1208 if (util_clip_region(x, y + border, border, h - border * 2,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1209 rx, ry, rw, rh,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1210 &fx, &fy, &fw, &fh))
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1211 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1212 pixbuf_draw_fade_linear(p_pix, prs, p_alpha,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1213 x + border, TRUE, border,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1214 fx, fy, fx + fw, fy + fh,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1215 r, g, b, a);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1216 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1217 if (util_clip_region(x + w - border, y + border, border, h - border * 2,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1218 rx, ry, rw, rh,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1219 &fx, &fy, &fw, &fh))
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1220 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1221 pixbuf_draw_fade_linear(p_pix, prs, p_alpha,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1222 x + w - border, TRUE, border,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1223 fx, fy, fx + fw, fy + fh,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1224 r, g, b, a);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1225 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1226 if (util_clip_region(x + border, y, w - border * 2, border,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1227 rx, ry, rw, rh,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1228 &fx, &fy, &fw, &fh))
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1229 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1230 pixbuf_draw_fade_linear(p_pix, prs, p_alpha,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1231 y + border, FALSE, border,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1232 fx, fy, fx + fw, fy + fh,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1233 r, g, b, a);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1234 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1235 if (util_clip_region(x + border, y + h - border, w - border * 2, border,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1236 rx, ry, rw, rh,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1237 &fx, &fy, &fw, &fh))
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1238 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1239 pixbuf_draw_fade_linear(p_pix, prs, p_alpha,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1240 y + h - border, FALSE, border,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1241 fx, fy, fx + fw, fy + fh,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1242 r, g, b, a);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1243 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1244 if (util_clip_region(x, y, border, border,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1245 rx, ry, rw, rh,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1246 &fx, &fy, &fw, &fh))
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1247 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1248 pixbuf_draw_fade_radius(p_pix, prs, p_alpha,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1249 x + border, y + border, border,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1250 fx, fy, fx + fw, fy + fh,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1251 r, g, b, a);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1252 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1253 if (util_clip_region(x + w - border, y, border, border,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1254 rx, ry, rw, rh,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1255 &fx, &fy, &fw, &fh))
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1256 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1257 pixbuf_draw_fade_radius(p_pix, prs, p_alpha,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1258 x + w - border, y + border, border,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1259 fx, fy, fx + fw, fy + fh,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1260 r, g, b, a);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1261 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1262 if (util_clip_region(x, y + h - border, border, border,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1263 rx, ry, rw, rh,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1264 &fx, &fy, &fw, &fh))
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1265 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1266 pixbuf_draw_fade_radius(p_pix, prs, p_alpha,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1267 x + border, y + h - border, border,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1268 fx, fy, fx + fw, fy + fh,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1269 r, g, b, a);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1270 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1271 if (util_clip_region(x + w - border, y + h - border, border, border,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1272 rx, ry, rw, rh,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1273 &fx, &fy, &fw, &fh))
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1274 {
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1275 pixbuf_draw_fade_radius(p_pix, prs, p_alpha,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1276 x + w - border, y + h - border, border,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1277 fx, fy, fx + fw, fy + fh,
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1278 r, g, b, a);
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1279 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1280 }
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1281
a41ecbb26a96 Wed Apr 6 06:41:25 2005 John Ellis <johne@verizon.net>
gqview
parents: 12
diff changeset
1282
82
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1283 /*
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1284 *-----------------------------------------------------------------------------
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1285 * pixbuf color alterations
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1286 *-----------------------------------------------------------------------------
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1287 */
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1288
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1289 void pixbuf_desaturate_rect(GdkPixbuf *pb,
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1290 gint x, gint y, gint w, gint h)
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1291 {
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1292 gint p_alpha;
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1293 gint pw, ph, prs;
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1294 guchar *p_pix;
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1295 guchar *pp;
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1296 gint i, j;
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1297
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1298 if (!pb) return;
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1299
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1300 pw = gdk_pixbuf_get_width(pb);
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1301 ph = gdk_pixbuf_get_height(pb);
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1302
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1303 if (x < 0 || x + w > pw) return;
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1304 if (y < 0 || y + h > ph) return;
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1305
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1306 p_alpha = gdk_pixbuf_get_has_alpha(pb);
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1307 prs = gdk_pixbuf_get_rowstride(pb);
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1308 p_pix = gdk_pixbuf_get_pixels(pb);
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1309
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 288
diff changeset
1310 for (i = 0; i < h; i++)
82
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1311 {
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1312 pp = p_pix + (y + i) * prs + (x * (p_alpha ? 4 : 3));
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1313 for (j = 0; j < w; j++)
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1314 {
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1315 guint8 grey;
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1316
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1317 grey = (pp[0] + pp[1] + pp[2]) / 3;
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1318 *pp = grey;
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1319 pp++;
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1320 *pp = grey;
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1321 pp++;
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1322 *pp = grey;
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1323 pp++;
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1324 if (p_alpha) pp++;
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1325 }
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1326 }
a4c1b7014e6e Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
diff changeset
1327 }