ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/CV/CV.xs
(Generate patch)

Comparing CV/CV.xs (file contents):
Revision 1.6 by root, Wed Nov 12 00:59:01 2003 UTC vs.
Revision 1.7 by root, Wed Nov 12 23:54:54 2003 UTC

9 9
10#define IW 80 10#define IW 80
11 11
12#define RAND (seed = (seed + 7141) * 54773 % 134456) 12#define RAND (seed = (seed + 7141) * 54773 % 134456)
13 13
14#define LINELENGTH 240
15
14#define ELLIPSIS "\xe2\x80\xa6" 16#define ELLIPSIS "\xe2\x80\xa6"
15 17
16static guint32 a85_val; 18static guint32 a85_val;
17static guint a85_cnt; 19static guint a85_cnt;
18static guchar a85_buf[80], *a85_ptr; 20static guchar a85_buf[LINELENGTH], *a85_ptr;
19 21
20static void 22static void
21a85_init (void) 23a85_init (void)
22{ 24{
23 a85_cnt = 4; 25 a85_cnt = 4;
77transpose (GdkPixbuf *pb) 79transpose (GdkPixbuf *pb)
78 CODE: 80 CODE:
79{ 81{
80 int w = gdk_pixbuf_get_width (pb); 82 int w = gdk_pixbuf_get_width (pb);
81 int h = gdk_pixbuf_get_height (pb); 83 int h = gdk_pixbuf_get_height (pb);
82 int bpp = gdk_pixbuf_get_has_alpha (pb) ? 4 : 3; 84 int bpp = gdk_pixbuf_get_n_channels (pb);
83 int x, y, i; 85 int x, y, i;
84 guchar *src = gdk_pixbuf_get_pixels (pb), *dst; 86 guchar *src = gdk_pixbuf_get_pixels (pb), *dst;
85 int sstr = gdk_pixbuf_get_rowstride (pb), dstr; 87 int sstr = gdk_pixbuf_get_rowstride (pb), dstr;
86 88
87 RETVAL = gdk_pixbuf_new (GDK_COLORSPACE_RGB, bpp == 4, 8, h, w); 89 RETVAL = gdk_pixbuf_new (GDK_COLORSPACE_RGB, bpp == 4, 8, h, w);
101flop (GdkPixbuf *pb) 103flop (GdkPixbuf *pb)
102 CODE: 104 CODE:
103{ 105{
104 int w = gdk_pixbuf_get_width (pb); 106 int w = gdk_pixbuf_get_width (pb);
105 int h = gdk_pixbuf_get_height (pb); 107 int h = gdk_pixbuf_get_height (pb);
106 int bpp = gdk_pixbuf_get_has_alpha (pb) ? 4 : 3; 108 int bpp = gdk_pixbuf_get_n_channels (pb);
107 int x, y, i; 109 int x, y, i;
108 guchar *src = gdk_pixbuf_get_pixels (pb), *dst; 110 guchar *src = gdk_pixbuf_get_pixels (pb), *dst;
109 int sstr = gdk_pixbuf_get_rowstride (pb), dstr; 111 int sstr = gdk_pixbuf_get_rowstride (pb), dstr;
110 112
111 RETVAL = gdk_pixbuf_new (GDK_COLORSPACE_RGB, bpp == 4, 8, w, h); 113 RETVAL = gdk_pixbuf_new (GDK_COLORSPACE_RGB, bpp == 4, 8, w, h);
156{ 158{
157 int w = gdk_pixbuf_get_width (pb); 159 int w = gdk_pixbuf_get_width (pb);
158 int h = gdk_pixbuf_get_height (pb); 160 int h = gdk_pixbuf_get_height (pb);
159 int x, y; 161 int x, y;
160 guchar *dst; 162 guchar *dst;
161 int bpp = gdk_pixbuf_get_has_alpha (pb) ? 4 : 3; 163 int bpp = gdk_pixbuf_get_n_channels (pb);
162 guchar *src = gdk_pixbuf_get_pixels (pb); 164 guchar *src = gdk_pixbuf_get_pixels (pb);
163 int sstr = gdk_pixbuf_get_rowstride (pb); 165 int sstr = gdk_pixbuf_get_rowstride (pb);
164 int Er[IW], Eg[IW], Eb[IW]; 166 int Er[IW], Eg[IW], Eb[IW];
165 int seed = 77; 167 int seed = 77;
166 168
211############################################################################# 213#############################################################################
212 214
213MODULE = Gtk2::CV PACKAGE = Gtk2::CV::PostScript 215MODULE = Gtk2::CV PACKAGE = Gtk2::CV::PostScript
214 216
215void 217void
216dump_pb (PerlIO *fp, GdkPixbuf *pb) 218dump_ascii85 (PerlIO *fp, GdkPixbuf *pb)
217 CODE: 219 CODE:
218{ 220{
219 int w = gdk_pixbuf_get_width (pb); 221 int w = gdk_pixbuf_get_width (pb);
220 int h = gdk_pixbuf_get_height (pb); 222 int h = gdk_pixbuf_get_height (pb);
221 int x, y, i; 223 int x, y, i;
222 guchar *dst; 224 guchar *dst;
223 int bpp = gdk_pixbuf_get_has_alpha (pb) ? 4 : 3; 225 int bpp = gdk_pixbuf_get_n_channels (pb);
224 guchar *src = gdk_pixbuf_get_pixels (pb); 226 guchar *src = gdk_pixbuf_get_pixels (pb);
225 int sstr = gdk_pixbuf_get_rowstride (pb); 227 int sstr = gdk_pixbuf_get_rowstride (pb);
226 228
227 a85_init (); 229 a85_init ();
228 230
229 for (y = 0; y < h; y++) 231 for (y = 0; y < h; y++)
230 for (x = 0; x < w; x++) 232 for (x = 0; x < w; x++)
231 for (i = 0; i < 3; i++) 233 for (i = 0; i < (bpp < 3 ? 1 : 3); i++)
232 a85_push (fp, src [x * bpp + y * sstr + i]); 234 a85_push (fp, src [x * bpp + y * sstr + i]);
233 235
234 a85_finish (fp); 236 a85_finish (fp);
235} 237}
236 238
239void
240dump_binary (PerlIO *fp, GdkPixbuf *pb)
241 CODE:
242{
243 int w = gdk_pixbuf_get_width (pb);
244 int h = gdk_pixbuf_get_height (pb);
245 int x, y, i;
246 guchar *dst;
247 int bpp = gdk_pixbuf_get_n_channels (pb);
248 guchar *src = gdk_pixbuf_get_pixels (pb);
249 int sstr = gdk_pixbuf_get_rowstride (pb);
237 250
251 for (y = 0; y < h; y++)
252 for (x = 0; x < w; x++)
253 for (i = 0; i < (bpp < 3 ? 1 : 3); i++)
254 PerlIO_putc (fp, src [x * bpp + y * sstr + i]);
255}
238 256
239 257
258
259

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines