[rt #74540] handle the TIFF SampleFormat tag
[imager.git] / TIFF / TIFF.xs
CommitLineData
e5ee047b
TC
1#define PERL_NO_GET_CONTEXT
2#ifdef __cplusplus
3extern "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
12DEFINE_IMAGER_CALLBACKS;
13
05c9b356
TC
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
e5ee047b
TC
20MODULE = Imager::File::TIFF PACKAGE = Imager::File::TIFF
21
22Imager::ImgRaw
23i_readtiff_wiol(ig, allow_incomplete=0, page=0)
24 Imager::IO ig
25 int allow_incomplete
26 int page
27
28void
29i_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
48undef_int
49i_writetiff_wiol(im, ig)
50 Imager::ImgRaw im
51 Imager::IO ig
52
53undef_int
54i_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
94undef_int
95i_writetiff_wiol_faxable(im, ig, fine)
96 Imager::ImgRaw im
97 Imager::IO ig
98 int fine
99
100undef_int
101i_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
142const char *
143i_tiff_libversion()
144
145bool
146i_tiff_has_compression(name)
147 const char *name
148
05c9b356
TC
149SV *
150i_tiff_ieeefp()
e5ee047b
TC
151
152BOOT:
153 PERL_INITIALIZE_IMAGER_CALLBACKS;
33ca1a7e 154 i_tiff_init();