Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

135 lines (124 sloc) 2.965 kb
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "imext.h"
#include "imperl.h"
#include "imicon.h"
#include "ppport.h"
DEFINE_IMAGER_CALLBACKS;
MODULE = Imager::File::ICO PACKAGE = Imager::File::ICO
PROTOTYPES: DISABLE
Imager::ImgRaw
i_readico_single(ig, index, masked = 0)
Imager::IO ig
int index
bool masked
void
i_readico_multi(ig, masked = 0)
Imager::IO ig
bool masked
PREINIT:
i_img **imgs;
int count;
int i;
PPCODE:
imgs = i_readico_multi(ig, &count, masked);
if (imgs) {
EXTEND(SP, count);
for (i = 0; i < count; ++i) {
SV *sv = sv_newmortal();
sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]);
PUSHs(sv);
}
myfree(imgs);
}
int
i_writeico_wiol(ig, im)
Imager::IO ig
Imager::ImgRaw im
undef_int
i_writeico_multi_wiol(ig, ...)
Imager::IO ig
PREINIT:
int i;
int img_count;
i_img **imgs;
CODE:
if (items < 2)
croak("Usage: i_writeico_multi_wiol(ig, images...)");
img_count = items - 1;
RETVAL = 1;
if (img_count < 1) {
RETVAL = 0;
i_clear_error();
i_push_error(0, "You need to specify images to save");
}
else {
imgs = mymalloc(sizeof(i_img *) * img_count);
for (i = 0; i < img_count; ++i) {
SV *sv = ST(1+i);
imgs[i] = NULL;
if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) {
imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(sv)));
}
else {
i_clear_error();
i_push_error(0, "Only images can be saved");
myfree(imgs);
RETVAL = 0;
break;
}
}
if (RETVAL) {
RETVAL = i_writeico_multi_wiol(ig, imgs, img_count);
}
myfree(imgs);
}
OUTPUT:
RETVAL
int
i_writecur_wiol(ig, im)
Imager::IO ig
Imager::ImgRaw im
undef_int
i_writecur_multi_wiol(ig, ...)
Imager::IO ig
PREINIT:
int i;
int img_count;
i_img **imgs;
CODE:
if (items < 2)
croak("Usage: i_writecur_multi_wiol(ig, images...)");
img_count = items - 1;
RETVAL = 1;
if (img_count < 1) {
RETVAL = 0;
i_clear_error();
i_push_error(0, "You need to specify images to save");
}
else {
imgs = mymalloc(sizeof(i_img *) * img_count);
for (i = 0; i < img_count; ++i) {
SV *sv = ST(1+i);
imgs[i] = NULL;
if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) {
imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(sv)));
}
else {
i_clear_error();
i_push_error(0, "Only images can be saved");
myfree(imgs);
RETVAL = 0;
break;
}
}
if (RETVAL) {
RETVAL = i_writecur_multi_wiol(ig, imgs, img_count);
}
myfree(imgs);
}
OUTPUT:
RETVAL
BOOT:
PERL_INITIALIZE_IMAGER_CALLBACKS;
Jump to Line
Something went wrong with that request. Please try again.