Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 135 lines (125 sloc) 2.993 kb
b13a3ddb » Tony Cook
2010-05-06 - use PERL_NO_GET_CONTEXT to slightly improve performance on threaded
1 #define PERL_NO_GET_CONTEXT
b00687b2 » Tony Cook
2006-03-24 - implement reading MS Windows icon files
2 #include "EXTERN.h"
3 #include "perl.h"
4 #include "XSUB.h"
5 #include "imext.h"
6 #include "imperl.h"
7 #include "imicon.h"
13eb8ccd » Tony Cook
2006-07-05 minor changes for compatibility with 5.005_03
8 #include "ppport.h"
b00687b2 » Tony Cook
2006-03-24 - implement reading MS Windows icon files
9
10 DEFINE_IMAGER_CALLBACKS;
11
12 MODULE = Imager::File::ICO PACKAGE = Imager::File::ICO
13
14 PROTOTYPES: DISABLE
15
16 Imager::ImgRaw
413dc198 » Tony Cook
2007-08-27 treat the ico mask as an alpha channel, since this is less confusing
17 i_readico_single(ig, index, masked = 0)
b00687b2 » Tony Cook
2006-03-24 - implement reading MS Windows icon files
18 Imager::IO ig
19 int index
413dc198 » Tony Cook
2007-08-27 treat the ico mask as an alpha channel, since this is less confusing
20 bool masked
b00687b2 » Tony Cook
2006-03-24 - implement reading MS Windows icon files
21
22 void
413dc198 » Tony Cook
2007-08-27 treat the ico mask as an alpha channel, since this is less confusing
23 i_readico_multi(ig, masked = 0)
b00687b2 » Tony Cook
2006-03-24 - implement reading MS Windows icon files
24 Imager::IO ig
413dc198 » Tony Cook
2007-08-27 treat the ico mask as an alpha channel, since this is less confusing
25 bool masked
b00687b2 » Tony Cook
2006-03-24 - implement reading MS Windows icon files
26 PREINIT:
27 i_img **imgs;
28 int count;
29 int i;
30 PPCODE:
413dc198 » Tony Cook
2007-08-27 treat the ico mask as an alpha channel, since this is less confusing
31 imgs = i_readico_multi(ig, &count, masked);
b00687b2 » Tony Cook
2006-03-24 - implement reading MS Windows icon files
32 if (imgs) {
33 EXTEND(SP, count);
34 for (i = 0; i < count; ++i) {
35 SV *sv = sv_newmortal();
36 sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]);
37 PUSHs(sv);
38 }
39 myfree(imgs);
40 }
41
2b405c9e » Tony Cook
2006-06-26 add support for file write plugins
42 int
43 i_writeico_wiol(ig, im)
44 Imager::IO ig
45 Imager::ImgRaw im
46
47 undef_int
48 i_writeico_multi_wiol(ig, ...)
49 Imager::IO ig
50 PREINIT:
51 int i;
52 int img_count;
53 i_img **imgs;
54 CODE:
55 if (items < 2)
56 croak("Usage: i_writeico_multi_wiol(ig, images...)");
57 img_count = items - 1;
58 RETVAL = 1;
59 if (img_count < 1) {
60 RETVAL = 0;
61 i_clear_error();
62 i_push_error(0, "You need to specify images to save");
63 }
64 else {
65 imgs = mymalloc(sizeof(i_img *) * img_count);
66 for (i = 0; i < img_count; ++i) {
67 SV *sv = ST(1+i);
68 imgs[i] = NULL;
69 if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) {
70 imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(sv)));
71 }
72 else {
73 i_clear_error();
74 i_push_error(0, "Only images can be saved");
75 myfree(imgs);
76 RETVAL = 0;
77 break;
78 }
79 }
80 if (RETVAL) {
81 RETVAL = i_writeico_multi_wiol(ig, imgs, img_count);
82 }
83 myfree(imgs);
84 }
85 OUTPUT:
86 RETVAL
87
88 int
89 i_writecur_wiol(ig, im)
90 Imager::IO ig
91 Imager::ImgRaw im
92
93 undef_int
94 i_writecur_multi_wiol(ig, ...)
95 Imager::IO ig
96 PREINIT:
97 int i;
98 int img_count;
99 i_img **imgs;
100 CODE:
101 if (items < 2)
102 croak("Usage: i_writecur_multi_wiol(ig, images...)");
103 img_count = items - 1;
104 RETVAL = 1;
105 if (img_count < 1) {
106 RETVAL = 0;
107 i_clear_error();
108 i_push_error(0, "You need to specify images to save");
109 }
110 else {
111 imgs = mymalloc(sizeof(i_img *) * img_count);
112 for (i = 0; i < img_count; ++i) {
113 SV *sv = ST(1+i);
114 imgs[i] = NULL;
115 if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) {
116 imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(sv)));
117 }
118 else {
119 i_clear_error();
120 i_push_error(0, "Only images can be saved");
121 myfree(imgs);
122 RETVAL = 0;
123 break;
124 }
125 }
126 if (RETVAL) {
127 RETVAL = i_writecur_multi_wiol(ig, imgs, img_count);
128 }
129 myfree(imgs);
130 }
131 OUTPUT:
132 RETVAL
b00687b2 » Tony Cook
2006-03-24 - implement reading MS Windows icon files
133
134 BOOT:
135 PERL_INITIALIZE_IMAGER_CALLBACKS;
Something went wrong with that request. Please try again.