#include "iolayer.h"
-#include "imagei.h"
+#include "imageri.h"
#include "png.h"
/* Check to see if a file is a PNG file using png_sig_cmp(). png_sig_cmp()
undef_int
i_writepng_wiol(i_img *im, io_glue *ig) {
png_structp png_ptr;
- png_infop info_ptr;
+ png_infop info_ptr = NULL;
int width,height,y;
volatile int cspace,channels;
double xres, yres;
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL) {
- png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
+ png_destroy_write_struct(&png_ptr, &info_ptr);
return 0;
}
* error hadnling functions in the png_create_write_struct() call.
*/
if (setjmp(png_ptr->jmpbuf)) {
- png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
+ png_destroy_write_struct(&png_ptr, &info_ptr);
return(0);
}
}
else {
unsigned char *data = mymalloc(im->xsize * im->channels);
- if (data) {
- for (y = 0; y < height; y++) {
- i_gsamp(im, 0, im->xsize, y, data, NULL, im->channels);
- png_write_row(png_ptr, (png_bytep)data);
- }
- myfree(data);
- }
- else {
- png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
- return 0;
+ for (y = 0; y < height; y++) {
+ i_gsamp(im, 0, im->xsize, y, data, NULL, im->channels);
+ png_write_row(png_ptr, (png_bytep)data);
}
+ myfree(data);
}
png_write_end(png_ptr, info_ptr);
- png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
+ png_destroy_write_struct(&png_ptr, &info_ptr);
ig->closecb(ig);