File: TIFF.xs

package info (click to toggle)
libimager-perl 1.027%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,820 kB
  • sloc: perl: 32,971; ansic: 28,092; makefile: 52; cpp: 4
file content (182 lines) | stat: -rw-r--r-- 4,170 bytes parent folder | download | duplicates (2)
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#define PERL_NO_GET_CONTEXT
#ifdef __cplusplus
extern "C" {
#endif
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "imext.h"
#include "imperl.h"
#include "imtiff.h"

DEFINE_IMAGER_CALLBACKS;

#ifdef IEEEFP_TYPES
#define i_tiff_ieeefp() &PL_sv_yes
#else
#define i_tiff_ieeefp() &PL_sv_no
#endif

MODULE = Imager::File::TIFF  PACKAGE = Imager::File::TIFF

Imager::ImgRaw
i_readtiff_wiol(ig, allow_incomplete=0, page=0)
        Imager::IO     ig
	       int     allow_incomplete
               int     page

void
i_readtiff_multi_wiol(ig)
        Imager::IO     ig
      PREINIT:
        i_img **imgs;
        int count;
        int i;
      PPCODE:
        imgs = i_readtiff_multi_wiol(ig, &count);
        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);
        }


undef_int
i_writetiff_wiol(im, ig)
    Imager::ImgRaw     im
        Imager::IO     ig

undef_int
i_writetiff_multi_wiol(ig, ...)
        Imager::IO     ig
      PREINIT:
        int i;
        int img_count;
        i_img **imgs;
      CODE:
        if (items < 2)
          croak("Usage: i_writetiff_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_writetiff_multi_wiol(ig, imgs, img_count);
          }
	  myfree(imgs);
	}
      OUTPUT:
        RETVAL

undef_int
i_writetiff_wiol_faxable(im, ig, fine)
    Imager::ImgRaw     im
        Imager::IO     ig
	       int     fine

undef_int
i_writetiff_multi_wiol_faxable(ig, fine, ...)
        Imager::IO     ig
        int fine
      PREINIT:
        int i;
        int img_count;
        i_img **imgs;
      CODE:
        if (items < 3)
          croak("Usage: i_writetiff_multi_wiol_faxable(ig, fine, images...)");
        img_count = items - 2;
        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(2+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_writetiff_multi_wiol_faxable(ig, imgs, img_count, fine);
          }
	  myfree(imgs);
	}
      OUTPUT:
        RETVAL

bool
i_tiff_has_compression(name)
	const char *name

SV *
i_tiff_ieeefp()

MODULE = Imager::File::TIFF  PACKAGE = Imager::File::TIFF  PREFIX = i_tiff_

const char *
i_tiff_builddate(...)
  C_ARGS:

const char *
i_tiff_buildversion(...)
  C_ARGS:

const char *
i_tiff_libversion(...)
  C_ARGS:

void
i_tiff_codecs(class)
    PPCODE:
      size_t count;
      i_tiff_codec *codecs = i_tiff_get_codecs(&count);
      EXTEND(SP, count);
      for (int i = 0; i < count; ++i) {
        i_tiff_codec *codec = codecs + i;
        HV *hv = newHV();
        hv_stores(hv, "description", newSVpvn(codec->description, strlen(codec->description)));
        hv_stores(hv, "name",        newSVpv(codec->name, 0));
        hv_stores(hv, "code",        newSViv(codec->code));
        SV *rv = newRV_noinc((SV*)hv);
        PUSHs(sv_2mortal(rv));
      }
      myfree(codecs);

BOOT:
	PERL_INITIALIZE_IMAGER_CALLBACKS;
	i_tiff_init();