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

Comparing CV/CV.xs (file contents):
Revision 1.17 by root, Wed Jul 20 06:20:36 2005 UTC vs.
Revision 1.22 by root, Sun Aug 14 02:25:44 2005 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 4
5#include <string.h>
5#include <setjmp.h> 6#include <setjmp.h>
6 7
7#include <jpeglib.h> 8#include <jpeglib.h>
8#include <gdk-pixbuf/gdk-pixbuf.h> 9#include <gdk-pixbuf/gdk-pixbuf.h>
9 10
123 124
124MODULE = Gtk2::CV PACKAGE = Gtk2::CV 125MODULE = Gtk2::CV PACKAGE = Gtk2::CV
125 126
126PROTOTYPES: ENABLE 127PROTOTYPES: ENABLE
127 128
129# missing in Gtk2 perl module
130
131gboolean
132gdk_net_wm_supports (GdkAtom property)
133 CODE:
134#if defined(GDK_WINDOWING_X11) && !defined(GDK_MULTIHEAD_SAFE)
135 RETVAL = gdk_net_wm_supports (property);
136#else
137 RETVAL = 0;
138#endif
139 OUTPUT:
140 RETVAL
141
128GdkPixbuf_noinc * 142GdkPixbuf_noinc *
129transpose (GdkPixbuf *pb) 143transpose (GdkPixbuf *pb)
130 CODE: 144 CODE:
131{ 145{
132 int w = gdk_pixbuf_get_width (pb); 146 int w = gdk_pixbuf_get_width (pb);
224 { 238 {
225 cinfo.dct_method = JDCT_FASTEST; 239 cinfo.dct_method = JDCT_FASTEST;
226 cinfo.do_fancy_upsampling = FALSE; 240 cinfo.do_fancy_upsampling = FALSE;
227 241
228 while (cinfo.scale_denom < 8 242 while (cinfo.scale_denom < 8
229 && (cinfo.output_width >> 1) >= IW 243 && cinfo.output_width >= IW*4
230 && (cinfo.output_height >> 1) >= IH) 244 && cinfo.output_height >= IH*4)
231 { 245 {
232 cinfo.scale_denom <<= 1; 246 cinfo.scale_denom <<= 1;
233 jpeg_calc_output_dimensions (&cinfo); 247 jpeg_calc_output_dimensions (&cinfo);
234 } 248 }
235 } 249 }
268 282
269############################################################################# 283#############################################################################
270 284
271MODULE = Gtk2::CV PACKAGE = Gtk2::CV::Schnauzer 285MODULE = Gtk2::CV PACKAGE = Gtk2::CV::Schnauzer
272 286
287SV *
288foldcase (SV *pathsv)
289 PROTOTYPE: $
290 CODE:
291{
292 STRLEN plen;
293 U8 *path = SvPVutf8 (pathsv, plen);
294 U8 *pend = path + plen;
295 U8 dst [plen * 6 * 3], *dstp = dst;
296
297 while (path < pend)
298 {
299 U8 ch = *path;
300
301 if (ch >= 'a' && ch <= 'z')
302 *dstp++ = *path++;
303 else if (ch >= '0' && ch <= '9')
304 {
305 STRLEN el, nl = 0;
306 while (*path >= '0' && *path <= '9' && path < pend)
307 path++, nl++;
308
309 for (el = nl; el < 6; el++)
310 *dstp++ = '0';
311
312 memcpy (dstp, path - nl, nl);
313 dstp += nl;
314 }
315 else
316 {
317 STRLEN cl;
318 to_utf8_fold (path, dstp, &cl);
319 dstp += cl;
320 path += is_utf8_char (path);
321 }
322 }
323
324 RETVAL = newSVpvn (dst, dstp - dst);
325}
326 OUTPUT:
327 RETVAL
328
273GdkPixbuf_noinc * 329GdkPixbuf_noinc *
274p7_to_pb (int w, int h, guchar *src) 330p7_to_pb (int w, int h, guchar *src)
331 PROTOTYPE: @
275 CODE: 332 CODE:
276{ 333{
277 int x, y; 334 int x, y;
278 guchar *dst, *d; 335 guchar *dst, *d;
279 int dstr; 336 int dstr;
351 } 408 }
352} 409}
353 OUTPUT: 410 OUTPUT:
354 RETVAL 411 RETVAL
355 412
356SV *
357make_histogram (SV *ar)
358 CODE:
359{
360 int i;
361 AV *av, *result;
362
363 if (!SvROK (ar) || SvTYPE (SvRV (ar)) != SVt_PVAV)
364 croak ("Not an array ref as first argument to make_histogram");
365
366 av = (AV *) SvRV (ar);
367 result = newAV ();
368
369 for (i = 0; i <= av_len (av); ++i)
370 {
371 const int HISTSIZE = 64;
372
373 int j;
374 SV *sv = *av_fetch (av, i, 1);
375 STRLEN len;
376 char *buf = SvPVbyte (sv, len);
377
378 int tmphist[HISTSIZE];
379 float *hist;
380
381 SV *histsv = newSV (HISTSIZE * sizeof (float) + 1);
382 SvPOK_on (histsv);
383 SvCUR_set (histsv, HISTSIZE * sizeof (float));
384 hist = (float *)SvPVX (histsv);
385
386 Zero (tmphist, sizeof (tmphist), char);
387
388 for (j = len; j--; )
389 {
390 unsigned int idx
391 = ((*buf & 0xc0) >> 2)
392 | ((*buf & 0x18) >> 1)
393 | (*buf & 0x03);
394
395 ++tmphist[idx];
396 ++buf;
397 }
398
399 for (j = 0; j < HISTSIZE; ++j)
400 hist[j] = (float)tmphist[j] / (len + 1e-30);
401
402 av_push (result, histsv);
403 }
404
405 RETVAL = newRV_noinc ((SV *)result);
406}
407 OUTPUT:
408 RETVAL
409
410############################################################################# 413#############################################################################
411 414
412MODULE = Gtk2::CV PACKAGE = Gtk2::CV::PostScript 415MODULE = Gtk2::CV PACKAGE = Gtk2::CV::PostScript
413 416
414void 417void
537 } 540 }
538} 541}
539 OUTPUT: 542 OUTPUT:
540 RETVAL 543 RETVAL
541 544
545#############################################################################
542 546
547MODULE = Gtk2::CV PACKAGE = Gtk2::CV::Plugin::RCluster
543 548
549SV *
550make_histograms (SV *ar)
551 CODE:
552{
553 int i;
554 AV *av, *result;
555
556 if (!SvROK (ar) || SvTYPE (SvRV (ar)) != SVt_PVAV)
557 croak ("Not an array ref as first argument to make_histogram");
558
559 av = (AV *) SvRV (ar);
560 result = newAV ();
561
562 for (i = 0; i <= av_len (av); ++i)
563 {
564 const int HISTSIZE = 64;
565
566 int j;
567 SV *sv = *av_fetch (av, i, 1);
568 STRLEN len;
569 char *buf = SvPVbyte (sv, len);
570
571 int tmphist[HISTSIZE];
572 float *hist;
573
574 SV *histsv = newSV (HISTSIZE * sizeof (float) + 1);
575 SvPOK_on (histsv);
576 SvCUR_set (histsv, HISTSIZE * sizeof (float));
577 hist = (float *)SvPVX (histsv);
578
579 Zero (tmphist, sizeof (tmphist), char);
580
581 for (j = len; j--; )
582 {
583 unsigned int idx
584 = ((*buf & 0xc0) >> 2)
585 | ((*buf & 0x18) >> 1)
586 | (*buf & 0x03);
587
588 ++tmphist[idx];
589 ++buf;
590 }
591
592 for (j = 0; j < HISTSIZE; ++j)
593 hist[j] = (float)tmphist[j] / (len + 1e-30);
594
595 av_push (result, histsv);
596 }
597
598 RETVAL = newRV_noinc ((SV *)result);
599}
600 OUTPUT:
601 RETVAL
602
603

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines