--- CV/CV.xs 2005/07/22 06:14:25 1.20 +++ CV/CV.xs 2005/08/21 02:23:52 1.27 @@ -6,6 +6,8 @@ #include #include +#include +#include #include #include @@ -126,6 +128,43 @@ PROTOTYPES: ENABLE +# missing in Gtk2 perl module + +gboolean +gdk_net_wm_supports (GdkAtom property) + CODE: +#if defined(GDK_WINDOWING_X11) && !defined(GDK_MULTIHEAD_SAFE) + RETVAL = gdk_net_wm_supports (property); +#else + RETVAL = 0; +#endif + OUTPUT: + RETVAL + +GdkPixbuf_noinc * +dealpha_expose (GdkPixbuf *pb) + CODE: +{ + int w = gdk_pixbuf_get_width (pb); + int h = gdk_pixbuf_get_height (pb); + int bpp = gdk_pixbuf_get_n_channels (pb); + int x, y, i; + guchar *src = gdk_pixbuf_get_pixels (pb), *dst; + int sstr = gdk_pixbuf_get_rowstride (pb), dstr; + + RETVAL = gdk_pixbuf_new (GDK_COLORSPACE_RGB, 0, 8, w, h); + + dst = gdk_pixbuf_get_pixels (RETVAL); + dstr = gdk_pixbuf_get_rowstride (RETVAL); + + for (x = 0; x < w; x++) + for (y = 0; y < h; y++) + for (i = 0; i < 3; i++) + dst[x * 3 + y * dstr + i] = src[x * bpp + y * sstr + i]; +} + OUTPUT: + RETVAL + GdkPixbuf_noinc * transpose (GdkPixbuf *pb) CODE: @@ -175,7 +214,7 @@ RETVAL GdkPixbuf_noinc * -load_jpeg (char *path, int thumbnail=0) +load_jpeg (SV *path, int thumbnail=0) CODE: { struct jpeg_decompress_struct cinfo; @@ -184,9 +223,15 @@ int rs; FILE *fp; volatile GdkPixbuf *pb = 0; + gchar *filename; + RETVAL = 0; - if (!(fp = fopen (path, "rb"))) + filename = g_filename_from_utf8 (SvPVutf8_nolen (path), -1, 0, 0, 0); + fp = fopen (filename, "rb"); + g_free (filename); + + if (!fp) XSRETURN_UNDEF; cinfo.err = jpeg_std_error (&jerr.err); @@ -227,8 +272,8 @@ cinfo.do_fancy_upsampling = FALSE; while (cinfo.scale_denom < 8 - && (cinfo.output_width >> 1) >= IW - && (cinfo.output_height >> 1) >= IH) + && cinfo.output_width >= IW*4 + && cinfo.output_height >= IH*4) { cinfo.scale_denom <<= 1; jpeg_calc_output_dimensions (&cinfo); @@ -277,7 +322,7 @@ CODE: { STRLEN plen; - U8 *path = SvPVutf8 (pathsv, plen); + U8 *path = (U8 *)SvPVutf8 (pathsv, plen); U8 *pend = path + plen; U8 dst [plen * 6 * 3], *dstp = dst; @@ -308,18 +353,20 @@ } } - RETVAL = newSVpvn (dst, dstp - dst); + RETVAL = newSVpvn ((const char *)dst, dstp - dst); } OUTPUT: RETVAL GdkPixbuf_noinc * -p7_to_pb (int w, int h, guchar *src) +p7_to_pb (int w, int h, SV *src_sv) + PROTOTYPE: @ CODE: { int x, y; guchar *dst, *d; int dstr; + guchar *src = (guchar *)SvPVbyte_nolen (src_sv); RETVAL = gdk_pixbuf_new (GDK_COLORSPACE_RGB, 0, 8, w, h); dst = gdk_pixbuf_get_pixels (RETVAL); @@ -356,7 +403,7 @@ SvPOK_only (RETVAL); SvCUR_set (RETVAL, w * h); - dst = SvPVX (RETVAL); + dst = (guchar *)SvPVX (RETVAL); memset (Er, 0, sizeof (int) * IW); memset (Eg, 0, sizeof (int) * IW); @@ -460,7 +507,7 @@ SvPOK_only (RETVAL); SvCUR_set (RETVAL, 6 * 8 * 12 / 8); - dst = SvPVX (RETVAL); + dst = (guchar *)SvPVX (RETVAL); /* some primitive error distribution + random dithering */