… | |
… | |
225 | { |
225 | { |
226 | cinfo.dct_method = JDCT_FASTEST; |
226 | cinfo.dct_method = JDCT_FASTEST; |
227 | cinfo.do_fancy_upsampling = FALSE; |
227 | cinfo.do_fancy_upsampling = FALSE; |
228 | |
228 | |
229 | while (cinfo.scale_denom < 8 |
229 | while (cinfo.scale_denom < 8 |
230 | && (cinfo.output_width >> 1) >= IW |
230 | && cinfo.output_width >= IW*4 |
231 | && (cinfo.output_height >> 1) >= IH) |
231 | && cinfo.output_height >= IH*4) |
232 | { |
232 | { |
233 | cinfo.scale_denom <<= 1; |
233 | cinfo.scale_denom <<= 1; |
234 | jpeg_calc_output_dimensions (&cinfo); |
234 | jpeg_calc_output_dimensions (&cinfo); |
235 | } |
235 | } |
236 | } |
236 | } |
… | |
… | |
313 | OUTPUT: |
313 | OUTPUT: |
314 | RETVAL |
314 | RETVAL |
315 | |
315 | |
316 | GdkPixbuf_noinc * |
316 | GdkPixbuf_noinc * |
317 | p7_to_pb (int w, int h, guchar *src) |
317 | p7_to_pb (int w, int h, guchar *src) |
|
|
318 | PROTOTYPE: @ |
318 | CODE: |
319 | CODE: |
319 | { |
320 | { |
320 | int x, y; |
321 | int x, y; |
321 | guchar *dst, *d; |
322 | guchar *dst, *d; |
322 | int dstr; |
323 | int dstr; |
… | |
… | |
394 | } |
395 | } |
395 | } |
396 | } |
396 | OUTPUT: |
397 | OUTPUT: |
397 | RETVAL |
398 | RETVAL |
398 | |
399 | |
399 | SV * |
|
|
400 | make_histogram (SV *ar) |
|
|
401 | CODE: |
|
|
402 | { |
|
|
403 | int i; |
|
|
404 | AV *av, *result; |
|
|
405 | |
|
|
406 | if (!SvROK (ar) || SvTYPE (SvRV (ar)) != SVt_PVAV) |
|
|
407 | croak ("Not an array ref as first argument to make_histogram"); |
|
|
408 | |
|
|
409 | av = (AV *) SvRV (ar); |
|
|
410 | result = newAV (); |
|
|
411 | |
|
|
412 | for (i = 0; i <= av_len (av); ++i) |
|
|
413 | { |
|
|
414 | const int HISTSIZE = 64; |
|
|
415 | |
|
|
416 | int j; |
|
|
417 | SV *sv = *av_fetch (av, i, 1); |
|
|
418 | STRLEN len; |
|
|
419 | char *buf = SvPVbyte (sv, len); |
|
|
420 | |
|
|
421 | int tmphist[HISTSIZE]; |
|
|
422 | float *hist; |
|
|
423 | |
|
|
424 | SV *histsv = newSV (HISTSIZE * sizeof (float) + 1); |
|
|
425 | SvPOK_on (histsv); |
|
|
426 | SvCUR_set (histsv, HISTSIZE * sizeof (float)); |
|
|
427 | hist = (float *)SvPVX (histsv); |
|
|
428 | |
|
|
429 | Zero (tmphist, sizeof (tmphist), char); |
|
|
430 | |
|
|
431 | for (j = len; j--; ) |
|
|
432 | { |
|
|
433 | unsigned int idx |
|
|
434 | = ((*buf & 0xc0) >> 2) |
|
|
435 | | ((*buf & 0x18) >> 1) |
|
|
436 | | (*buf & 0x03); |
|
|
437 | |
|
|
438 | ++tmphist[idx]; |
|
|
439 | ++buf; |
|
|
440 | } |
|
|
441 | |
|
|
442 | for (j = 0; j < HISTSIZE; ++j) |
|
|
443 | hist[j] = (float)tmphist[j] / (len + 1e-30); |
|
|
444 | |
|
|
445 | av_push (result, histsv); |
|
|
446 | } |
|
|
447 | |
|
|
448 | RETVAL = newRV_noinc ((SV *)result); |
|
|
449 | } |
|
|
450 | OUTPUT: |
|
|
451 | RETVAL |
|
|
452 | |
|
|
453 | ############################################################################# |
400 | ############################################################################# |
454 | |
401 | |
455 | MODULE = Gtk2::CV PACKAGE = Gtk2::CV::PostScript |
402 | MODULE = Gtk2::CV PACKAGE = Gtk2::CV::PostScript |
456 | |
403 | |
457 | void |
404 | void |
… | |
… | |
580 | } |
527 | } |
581 | } |
528 | } |
582 | OUTPUT: |
529 | OUTPUT: |
583 | RETVAL |
530 | RETVAL |
584 | |
531 | |
|
|
532 | ############################################################################# |
585 | |
533 | |
|
|
534 | MODULE = Gtk2::CV PACKAGE = Gtk2::CV::Plugin::RCluster |
586 | |
535 | |
|
|
536 | SV * |
|
|
537 | make_histograms (SV *ar) |
|
|
538 | CODE: |
|
|
539 | { |
|
|
540 | int i; |
|
|
541 | AV *av, *result; |
|
|
542 | |
|
|
543 | if (!SvROK (ar) || SvTYPE (SvRV (ar)) != SVt_PVAV) |
|
|
544 | croak ("Not an array ref as first argument to make_histogram"); |
|
|
545 | |
|
|
546 | av = (AV *) SvRV (ar); |
|
|
547 | result = newAV (); |
|
|
548 | |
|
|
549 | for (i = 0; i <= av_len (av); ++i) |
|
|
550 | { |
|
|
551 | const int HISTSIZE = 64; |
|
|
552 | |
|
|
553 | int j; |
|
|
554 | SV *sv = *av_fetch (av, i, 1); |
|
|
555 | STRLEN len; |
|
|
556 | char *buf = SvPVbyte (sv, len); |
|
|
557 | |
|
|
558 | int tmphist[HISTSIZE]; |
|
|
559 | float *hist; |
|
|
560 | |
|
|
561 | SV *histsv = newSV (HISTSIZE * sizeof (float) + 1); |
|
|
562 | SvPOK_on (histsv); |
|
|
563 | SvCUR_set (histsv, HISTSIZE * sizeof (float)); |
|
|
564 | hist = (float *)SvPVX (histsv); |
|
|
565 | |
|
|
566 | Zero (tmphist, sizeof (tmphist), char); |
|
|
567 | |
|
|
568 | for (j = len; j--; ) |
|
|
569 | { |
|
|
570 | unsigned int idx |
|
|
571 | = ((*buf & 0xc0) >> 2) |
|
|
572 | | ((*buf & 0x18) >> 1) |
|
|
573 | | (*buf & 0x03); |
|
|
574 | |
|
|
575 | ++tmphist[idx]; |
|
|
576 | ++buf; |
|
|
577 | } |
|
|
578 | |
|
|
579 | for (j = 0; j < HISTSIZE; ++j) |
|
|
580 | hist[j] = (float)tmphist[j] / (len + 1e-30); |
|
|
581 | |
|
|
582 | av_push (result, histsv); |
|
|
583 | } |
|
|
584 | |
|
|
585 | RETVAL = newRV_noinc ((SV *)result); |
|
|
586 | } |
|
|
587 | OUTPUT: |
|
|
588 | RETVAL |
|
|
589 | |
|
|
590 | |