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

Comparing CV/CV.xs (file contents):
Revision 1.1 by root, Sun Nov 2 12:55:41 2003 UTC vs.
Revision 1.2 by root, Mon Nov 3 00:04:22 2003 UTC

1#include "EXTERN.h" 1#include "EXTERN.h"
2#include "perl.h" 2#include "perl.h"
3#include "XSUB.h" 3#include "XSUB.h"
4
5#include <gdk-pixbuf/gdk-pixbuf.h>
6
7#include <gperl.h>
8#include <gtk2perl.h>
4 9
5MODULE = Gtk2::CV PACKAGE = Gtk2::CV::ImageWindow 10MODULE = Gtk2::CV PACKAGE = Gtk2::CV::ImageWindow
6 11
7PROTOTYPES: ENABLE 12PROTOTYPES: ENABLE
8 13
14GdkPixbuf *
15transpose (GdkPixbuf *pb)
16 CODE:
17{
18 int w = gdk_pixbuf_get_width (pb);
19 int h = gdk_pixbuf_get_height (pb);
20 int bpp = gdk_pixbuf_get_has_alpha (pb) ? 4 : 3;
21 int x, y, i;
22 guchar *src = gdk_pixbuf_get_pixels (pb), *dst;
23 int sstr = gdk_pixbuf_get_rowstride (pb), dstr;
9 24
25 RETVAL = gdk_pixbuf_new (GDK_COLORSPACE_RGB, bpp == 4, 8, h, w);
26
27 dst = gdk_pixbuf_get_pixels (RETVAL);
28 dstr = gdk_pixbuf_get_rowstride (RETVAL);
29
30 for (x = 0; x < w; x++)
31 for (y = 0; y < h; y++)
32 for (i = 0; i < bpp; i++)
33 dst[y * bpp + x * dstr + i] = src[x * bpp + y * sstr + i];
34}
35 OUTPUT:
36 RETVAL
37
38GdkPixbuf *
39flop (GdkPixbuf *pb)
40 CODE:
41{
42 int w = gdk_pixbuf_get_width (pb);
43 int h = gdk_pixbuf_get_height (pb);
44 int bpp = gdk_pixbuf_get_has_alpha (pb) ? 4 : 3;
45 int x, y, i;
46 guchar *src = gdk_pixbuf_get_pixels (pb), *dst;
47 int sstr = gdk_pixbuf_get_rowstride (pb), dstr;
48
49 RETVAL = gdk_pixbuf_new (GDK_COLORSPACE_RGB, bpp == 4, 8, w, h);
50
51 dst = gdk_pixbuf_get_pixels (RETVAL);
52 dstr = gdk_pixbuf_get_rowstride (RETVAL);
53
54 for (x = 0; x < w; x++)
55 for (y = 0; y < h; y++)
56 for (i = 0; i < bpp; i++)
57 dst[(w - x) * bpp + y * dstr + i] = src[x *bpp + y * sstr + i];
58}
59 OUTPUT:
60 RETVAL
61
62MODULE = Gtk2::CV PACKAGE = Gtk2::CV::Schnauzer
63
64GdkPixbuf *
65p7_to_pb (int w, int h, guchar *src)
66 CODE:
67{
68 int x, y;
69 guchar *dst, *d;
70 int dstr;
71
72 RETVAL = gdk_pixbuf_new (GDK_COLORSPACE_RGB, 0, 8, w, h);
73 dst = gdk_pixbuf_get_pixels (RETVAL);
74 dstr = gdk_pixbuf_get_rowstride (RETVAL);
75
76 for (y = 0; y < h; y++)
77 for (d = dst + y * dstr, x = 0; x < w; x++)
78 {
79 *d++ = ((*src >> 5) & 7) * 255 / 7;
80 *d++ = ((*src >> 2) & 7) * 255 / 7;
81 *d++ = ((*src >> 0) & 3) * 255 / 3;
82
83 src++;
84 }
85}
86 OUTPUT:
87 RETVAL
88
89
90

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines