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

Comparing CV/CV.xs (file contents):
Revision 1.49 by root, Wed May 24 19:22:32 2017 UTC vs.
Revision 1.50 by root, Sat Dec 23 03:30:28 2017 UTC

9#include <magic.h> 9#include <magic.h>
10 10
11#include <jpeglib.h> 11#include <jpeglib.h>
12#include <glib.h> 12#include <glib.h>
13#include <gtk/gtk.h> 13#include <gtk/gtk.h>
14#include <gdk/gdkx.h>
14#include <gdk-pixbuf/gdk-pixbuf.h> 15#include <gdk-pixbuf/gdk-pixbuf.h>
15 16
16#include <gperl.h> 17#include <gperl.h>
17#include <gtk2perl.h> 18#include <gtk2perl.h>
18 19
19#include <assert.h> 20#include <assert.h>
21
22#if WEBP
23#include <webp/decode.h>
24#endif
20 25
21#include "perlmulticore.h" 26#include "perlmulticore.h"
22 27
23#define IW 80 /* MUST match Schnauzer.pm! */ 28#define IW 80 /* MUST match Schnauzer.pm! */
24#define IH 60 /* MUST match Schnauzer.pm! */ 29#define IH 60 /* MUST match Schnauzer.pm! */
313 : angle == 90 ? GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE 318 : angle == 90 ? GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE
314 : angle == 180 ? GDK_PIXBUF_ROTATE_UPSIDEDOWN 319 : angle == 180 ? GDK_PIXBUF_ROTATE_UPSIDEDOWN
315 : angle == 270 ? GDK_PIXBUF_ROTATE_CLOCKWISE 320 : angle == 270 ? GDK_PIXBUF_ROTATE_CLOCKWISE
316 : angle); 321 : angle);
317 perlinterp_acquire (); 322 perlinterp_acquire ();
323 OUTPUT:
324 RETVAL
325
326GdkPixbuf_noinc *
327load_webp (SV *image_data, int thumbnail = 0, int iw = 0, int ih = 0)
328 CODE:
329{
330#if WEBP
331 STRLEN data_size;
332 guchar *data = SvPVbyte (image_data, data_size);
333 int alpha;
334 WebPDecoderConfig config;
335
336 perlinterp_release ();
337
338 RETVAL = 0;
339
340 if (!WebPInitDecoderConfig (&config))
341 goto err;
342
343 config.options.use_threads = 1;
344
345 if (thumbnail)
346 {
347 config.options.bypass_filtering = 1;
348 config.options.no_fancy_upsampling = 1;
349
350 config.options.use_scaling = 1;
351 config.options.scaled_width = iw;
352 config.options.scaled_height = ih;
353 }
354 else
355 {
356 iw = config.input.width;
357 ih = config.input.height;
358 }
359
360 if (WebPGetFeatures (data, data_size, &config.input) != VP8_STATUS_OK)
361 goto err;
362
363 alpha = config.input.has_alpha;
364
365 RETVAL = gdk_pixbuf_new (GDK_COLORSPACE_RGB, !!alpha, 8, iw, ih);
366 if (!RETVAL)
367 goto err;
368
369 config.output.colorspace = alpha ? MODE_RGBA : MODE_RGB;
370 config.output.u.RGBA.rgba = gdk_pixbuf_get_pixels (RETVAL);
371 config.output.u.RGBA.stride = gdk_pixbuf_get_rowstride (RETVAL);
372 config.output.u.RGBA.size = gdk_pixbuf_get_byte_length (RETVAL);
373 config.output.is_external_memory = 1;
374
375 if (WebPDecode (data, data_size, &config) != VP8_STATUS_OK)
376 {
377 g_object_unref (RETVAL);
378 RETVAL = 0;
379 goto err;
380 }
381
382 err:
383 perlinterp_acquire ();
384#else
385 croak ("load_webp: webp not enabled at compile time");
386#endif
387}
318 OUTPUT: 388 OUTPUT:
319 RETVAL 389 RETVAL
320 390
321GdkPixbuf_noinc * 391GdkPixbuf_noinc *
322load_jpeg (SV *path, int thumbnail = 0, int iw = 0, int ih = 0) 392load_jpeg (SV *path, int thumbnail = 0, int iw = 0, int ih = 0)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines