Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

file 135 lines (125 sloc) 2.993 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
#define PERL_NO_GET_CONTEXT
#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;
Something went wrong with that request. Please try again.