5 #include <erl_driver_tk.h>
15 gdImagePtr
gdImageCreateFromXpm(FILE *); /* gd.h doesn't have a prototype */
18 my_gdImagePng(gdImagePtr im
, char *file
)
22 if ((fp
= fopen(file
, "wb")) == NULL
)
25 if (fclose(fp
) == EOF
)
32 my_gdImageJpeg(gdImagePtr im
, char *file
, int quality
)
36 if ((fp
= fopen(file
, "wb")) == NULL
)
38 gdImageJpeg(im
, fp
, quality
);
39 if (fclose(fp
) == EOF
)
46 my_gdImageCreateFromJpeg(char *file
, int *status
)
51 if ((fp
= fopen(file
, "rb")) == NULL
) {
55 if ((im
= gdImageCreateFromJpeg(fp
)) == NULL
) {
59 if (fclose(fp
) == EOF
) {
68 my_gdImageCreateFromPng(char *file
, int *status
)
73 if ((fp
= fopen(file
, "rb")) == NULL
) {
77 if ((im
= gdImageCreateFromPng(fp
)) == NULL
) {
81 if (fclose(fp
) == EOF
) {
90 my_gdImageCreateFromGd(char *file
, int *status
)
95 if ((fp
= fopen(file
, "rb")) == NULL
) {
99 if ((im
= gdImageCreateFromGd(fp
)) == NULL
) {
103 if (fclose(fp
) == EOF
) {
112 my_gdImageCreateFromGd2(char *file
, int *status
)
117 if ((fp
= fopen(file
, "rb")) == NULL
) {
121 if ((im
= gdImageCreateFromGd2(fp
)) == NULL
) {
125 if (fclose(fp
) == EOF
) {
134 my_gdImageCreateFromGd2Part(char *file
, int srcX
, int srcY
, int w
, int h
,
140 if ((fp
= fopen(file
, "rb")) == NULL
) {
144 if ((im
= gdImageCreateFromGd2Part(fp
, srcX
, srcY
, w
, h
)) == NULL
) {
148 if (fclose(fp
) == EOF
) {
157 my_gdImageCreateFromXpm(char *file
, int *status
)
162 if ((fp
= fopen(file
, "rb")) == NULL
) {
166 if ((im
= gdImageCreateFromXpm(fp
)) == NULL
) {
170 if (fclose(fp
) == EOF
) {
179 my_gdImageWBMP(gdImagePtr im
, int fg
, char *file
)
183 if ((fp
= fopen(file
, "wb")) == NULL
)
185 gdImageWBMP(im
, fg
, fp
);
186 if (fclose(fp
) == EOF
)
193 my_gdImageGd(gdImagePtr im
, char *file
)
197 if ((fp
= fopen(file
, "wb")) == NULL
)
200 if (fclose(fp
) == EOF
)
207 my_gdImageGd2(gdImagePtr im
, char *file
, int chunkSize
, int fmt
)
211 if ((fp
= fopen(file
, "wb")) == NULL
)
213 gdImageGd2(im
, fp
, chunkSize
, fmt
);
214 if (fclose(fp
) == EOF
)
221 my_gdImagePolygon(gdImagePtr im
, char *vertices
, int pointsTotal
, int color
)
223 gdPoint v
[MAX_POLYGON_VERTICES
];
226 if (pointsTotal
> MAX_POLYGON_VERTICES
) {
229 for (i
= 0; i
< pointsTotal
; i
++) {
230 v
[i
].x
= get_int32(vertices
);
232 v
[i
].y
= get_int32(vertices
);
235 gdImagePolygon(im
, v
, pointsTotal
, color
);
240 my_gdImageFilledPolygon(gdImagePtr im
, char *vertices
, int pointsTotal
, int color
)
242 gdPoint v
[MAX_POLYGON_VERTICES
];
245 if (pointsTotal
> MAX_POLYGON_VERTICES
) {
248 for (i
= 0; i
< pointsTotal
; i
++) {
249 v
[i
].x
= get_int32(vertices
);
251 v
[i
].y
= get_int32(vertices
);
254 gdImageFilledPolygon(im
, v
, pointsTotal
, color
);
259 my_gdImageSetStyle(gdImagePtr im
, char *style
, int styleLength
)
261 int v
[MAX_STYLE_LENGTH
];
264 if (styleLength
> MAX_STYLE_LENGTH
) {
267 for (i
= 0; i
< styleLength
; i
++) {
268 v
[i
] = get_int32(style
);
271 gdImageSetStyle(im
, v
, styleLength
);
276 my_GetFontPtr(int font_idx
)
279 case FONT_TINY
: return gdFontTiny
;
280 case FONT_SMALL
: return gdFontSmall
;
281 case FONT_MEDIUMBOLD
: return gdFontMediumBold
;
282 case FONT_LARGE
: return gdFontLarge
;
283 case FONT_GIANT
: return gdFontGiant
;
284 default: return NULL
;