Gimp
view release on metacpan or search on metacpan
lib/Gimp/Lib.xs view on Meta::CPAN
#define pTHX_
#endif
#include "perl-intl.h"
/* dirty is used in gimp.h AND in perl < 5.005 or with PERL_POLLUTE. */
#ifdef dirty
# undef dirty
#endif
#include "gimp-perl.h"
#define GIMP_PKG "Gimp::" /* the package name */
#define PKG_COLOR GIMP_PKG "Color"
#define PKG_ITEM GIMP_PKG "Item"
#define PKG_DISPLAY GIMP_PKG "Display"
#define PKG_IMAGE GIMP_PKG "Image"
#define PKG_LAYER GIMP_PKG "Layer"
#define PKG_CHANNEL GIMP_PKG "Channel"
#define PKG_DRAWABLE GIMP_PKG "Drawable"
#define PKG_SELECTION GIMP_PKG "Selection"
#define PKG_PARASITE GIMP_PKG "Parasite"
#define PKG_VECTORS GIMP_PKG "Vectors"
#define PKG_GDRAWABLE GIMP_PKG "GimpDrawable"
#define PKG_TILE GIMP_PKG "Tile"
#define PKG_PIXELRGN GIMP_PKG "PixelRgn"
#define PKG_ANY ((char *)0)
typedef GimpPixelRgn GimpPixelRgn_PDL;
static Core* PDL; /* Structure hold core C functions */
/* get pointer to PDL structure. */
static void need_pdl (void)
{
SV *CoreSV;
if (!PDL) {
require_pv("PDL/Core.pm");
CoreSV = get_sv("PDL::SHARE", FALSE);
if (CoreSV == NULL)
croak("gimp-perl-pixel functions require PDL::Core module - failed");
PDL = INT2PTR(Core*,SvIV( CoreSV ));
}
}
static pdl *new_pdl (int a, int b, int c)
{
pdl *p = PDL->pdlnew();
PDL_Indx dims[3];
int ndims = 0;
if (c > 0) dims[ndims++] = c;
if (b > 0) dims[ndims++] = b;
if (a > 0) dims[ndims++] = a;
PDL->setdims (p, dims, ndims);
p->datatype = PDL_B;
PDL->allocdata (p);
return p;
}
static void old_pdl (pdl **p, short ndims, int dim0)
{
*p = PDL->get_convertedpdl(*p, PDL_B);
PDL->make_physical (*p);
if ((*p)->ndims < ndims + (dim0 > 1))
croak (__("dimension mismatch, pdl has dimension %d but at least %d dimensions required"), (*p)->ndims, ndims + (dim0 > 1));
if ((*p)->ndims > ndims + 1)
croak (__("dimension mismatch, pdl has dimension %d but at most %d dimensions allowed"), (*p)->ndims, ndims + 1);
if ((*p)->ndims > ndims && (*p)->dims[0] != dim0)
croak (__("pixel size mismatch, pdl has %d channel pixels but %d channels are required"), (*p)->dims[0], dim0);
}
static void pixel_rgn_pdl_delete_data (pdl *p, size_t param)
{
p->data = 0;
}
static pdl *redim_pdl (pdl *p, int ndim, int newsize)
{
pdl *r = PDL->pdlnew();
PDL_Indx dims[p->ndims], i; /* copy so as to modify */
for (i = 0; i < p->ndims; i++) dims[i] = p->dims[i];
dims[ndim] = newsize;
PDL->affine_new (p, r, 0,
dims, p->ndims,
p->dimincs, p->ndims);
return r;
}
/* set when it's safe to call gimp functions. */
static int gimp_is_initialized = 0;
typedef gint32 IMAGE;
typedef gint32 LAYER;
typedef gint32 CHANNEL;
typedef gint32 DRAWABLE;
typedef gint32 SELECTION;
typedef gint32 DISPLAY;
typedef gint32 ITEM;
typedef gint32 COLOR;
typedef gpointer GimpPixelRgnIterator;
#define verbose_level SvIV(get_sv("Gimp::verbose", TRUE))
#ifndef __STDC__
#error You need to compile with an ansi-c compiler!!!
#error Remove these lines to continue at your own risk!
#endif
#if __STDC_VERSION__ > 199900 || __GNUC__
#define verbose_printf(level, ...) \
do { \
if (verbose_level >= level) PerlIO_printf (PerlIO_stderr (), __VA_ARGS__); \
( run in 1.371 second using v1.01-cache-2.11-cpan-39bf76dae61 )