| 1 |
#define PERL_NO_GET_CONTEXT |
| 2 |
#ifdef __cplusplus |
| 3 |
extern "C" { |
| 4 |
#endif |
| 5 |
#include "EXTERN.h" |
| 6 |
#include "perl.h" |
| 7 |
#include "XSUB.h" |
| 8 |
#include "imext.h" |
| 9 |
#include "imperl.h" |
| 10 |
#include "imtiff.h" |
| 11 |
|
| 12 |
DEFINE_IMAGER_CALLBACKS; |
| 13 |
|
| 14 |
#ifdef IEEEFP_TYPES |
| 15 |
#define i_tiff_ieeefp() &PL_sv_yes |
| 16 |
#else |
| 17 |
#define i_tiff_ieeefp() &PL_sv_no |
| 18 |
#endif |
| 19 |
|
| 20 |
MODULE = Imager::File::TIFF PACKAGE = Imager::File::TIFF |
| 21 |
|
| 22 |
Imager::ImgRaw |
| 23 |
i_readtiff_wiol(ig, allow_incomplete=0, page=0) |
| 24 |
Imager::IO ig |
| 25 |
int allow_incomplete |
| 26 |
int page |
| 27 |
|
| 28 |
void |
| 29 |
i_readtiff_multi_wiol(ig) |
| 30 |
Imager::IO ig |
| 31 |
PREINIT: |
| 32 |
i_img **imgs; |
| 33 |
int count; |
| 34 |
int i; |
| 35 |
PPCODE: |
| 36 |
imgs = i_readtiff_multi_wiol(ig, &count); |
| 37 |
if (imgs) { |
| 38 |
EXTEND(SP, count); |
| 39 |
for (i = 0; i < count; ++i) { |
| 40 |
SV *sv = sv_newmortal(); |
| 41 |
sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]); |
| 42 |
PUSHs(sv); |
| 43 |
} |
| 44 |
myfree(imgs); |
| 45 |
} |
| 46 |
|
| 47 |
|
| 48 |
undef_int |
| 49 |
i_writetiff_wiol(im, ig) |
| 50 |
Imager::ImgRaw im |
| 51 |
Imager::IO ig |
| 52 |
|
| 53 |
undef_int |
| 54 |
i_writetiff_multi_wiol(ig, ...) |
| 55 |
Imager::IO ig |
| 56 |
PREINIT: |
| 57 |
int i; |
| 58 |
int img_count; |
| 59 |
i_img **imgs; |
| 60 |
CODE: |
| 61 |
if (items < 2) |
| 62 |
croak("Usage: i_writetiff_multi_wiol(ig, images...)"); |
| 63 |
img_count = items - 1; |
| 64 |
RETVAL = 1; |
| 65 |
if (img_count < 1) { |
| 66 |
RETVAL = 0; |
| 67 |
i_clear_error(); |
| 68 |
i_push_error(0, "You need to specify images to save"); |
| 69 |
} |
| 70 |
else { |
| 71 |
imgs = mymalloc(sizeof(i_img *) * img_count); |
| 72 |
for (i = 0; i < img_count; ++i) { |
| 73 |
SV *sv = ST(1+i); |
| 74 |
imgs[i] = NULL; |
| 75 |
if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) { |
| 76 |
imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(sv))); |
| 77 |
} |
| 78 |
else { |
| 79 |
i_clear_error(); |
| 80 |
i_push_error(0, "Only images can be saved"); |
| 81 |
myfree(imgs); |
| 82 |
RETVAL = 0; |
| 83 |
break; |
| 84 |
} |
| 85 |
} |
| 86 |
if (RETVAL) { |
| 87 |
RETVAL = i_writetiff_multi_wiol(ig, imgs, img_count); |
| 88 |
} |
| 89 |
myfree(imgs); |
| 90 |
} |
| 91 |
OUTPUT: |
| 92 |
RETVAL |
| 93 |
|
| 94 |
undef_int |
| 95 |
i_writetiff_wiol_faxable(im, ig, fine) |
| 96 |
Imager::ImgRaw im |
| 97 |
Imager::IO ig |
| 98 |
int fine |
| 99 |
|
| 100 |
undef_int |
| 101 |
i_writetiff_multi_wiol_faxable(ig, fine, ...) |
| 102 |
Imager::IO ig |
| 103 |
int fine |
| 104 |
PREINIT: |
| 105 |
int i; |
| 106 |
int img_count; |
| 107 |
i_img **imgs; |
| 108 |
CODE: |
| 109 |
if (items < 3) |
| 110 |
croak("Usage: i_writetiff_multi_wiol_faxable(ig, fine, images...)"); |
| 111 |
img_count = items - 2; |
| 112 |
RETVAL = 1; |
| 113 |
if (img_count < 1) { |
| 114 |
RETVAL = 0; |
| 115 |
i_clear_error(); |
| 116 |
i_push_error(0, "You need to specify images to save"); |
| 117 |
} |
| 118 |
else { |
| 119 |
imgs = mymalloc(sizeof(i_img *) * img_count); |
| 120 |
for (i = 0; i < img_count; ++i) { |
| 121 |
SV *sv = ST(2+i); |
| 122 |
imgs[i] = NULL; |
| 123 |
if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) { |
| 124 |
imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(sv))); |
| 125 |
} |
| 126 |
else { |
| 127 |
i_clear_error(); |
| 128 |
i_push_error(0, "Only images can be saved"); |
| 129 |
myfree(imgs); |
| 130 |
RETVAL = 0; |
| 131 |
break; |
| 132 |
} |
| 133 |
} |
| 134 |
if (RETVAL) { |
| 135 |
RETVAL = i_writetiff_multi_wiol_faxable(ig, imgs, img_count, fine); |
| 136 |
} |
| 137 |
myfree(imgs); |
| 138 |
} |
| 139 |
OUTPUT: |
| 140 |
RETVAL |
| 141 |
|
| 142 |
bool |
| 143 |
i_tiff_has_compression(name) |
| 144 |
const char *name |
| 145 |
|
| 146 |
SV * |
| 147 |
i_tiff_ieeefp() |
| 148 |
|
| 149 |
MODULE = Imager::File::TIFF PACKAGE = Imager::File::TIFF PREFIX = i_tiff_ |
| 150 |
|
| 151 |
const char * |
| 152 |
i_tiff_builddate(...) |
| 153 |
CODE: |
| 154 |
(void)items; /* the ... args means items is unused */ |
| 155 |
RETVAL = i_tiff_builddate(); |
| 156 |
OUTPUT: RETVAL |
| 157 |
|
| 158 |
const char * |
| 159 |
i_tiff_buildversion(...) |
| 160 |
CODE: |
| 161 |
(void)items; /* the ... args means items is unused */ |
| 162 |
RETVAL = i_tiff_buildversion(); |
| 163 |
OUTPUT: RETVAL |
| 164 |
|
| 165 |
const char * |
| 166 |
i_tiff_libversion(...) |
| 167 |
CODE: |
| 168 |
(void)items; /* the ... args means items is unused */ |
| 169 |
RETVAL = i_tiff_libversion(); |
| 170 |
OUTPUT: RETVAL |
| 171 |
|
| 172 |
void |
| 173 |
i_tiff_codecs(class) |
| 174 |
PPCODE: |
| 175 |
size_t count; |
| 176 |
i_tiff_codec *codecs = i_tiff_get_codecs(&count); |
| 177 |
EXTEND(SP, (ssize_t)count); |
| 178 |
for (unsigned i = 0; i < count; ++i) { |
| 179 |
i_tiff_codec *codec = codecs + i; |
| 180 |
HV *hv = newHV(); |
| 181 |
hv_stores(hv, "description", newSVpvn(codec->description, strlen(codec->description))); |
| 182 |
hv_stores(hv, "name", newSVpv(codec->name, 0)); |
| 183 |
hv_stores(hv, "code", newSViv(codec->code)); |
| 184 |
SV *rv = newRV_noinc((SV*)hv); |
| 185 |
PUSHs(sv_2mortal(rv)); |
| 186 |
} |
| 187 |
myfree(codecs); |
| 188 |
|
| 189 |
BOOT: |
| 190 |
PERL_INITIALIZE_IMAGER_CALLBACKS_NAME("Imager::File::TIFF"); |
| 191 |
i_tiff_init(); |