diff options
-rw-r--r-- | src/flam3-animate.c | 4 | ||||
-rw-r--r-- | src/flam3-render.c | 8 | ||||
-rwxr-xr-x | src/png.c | 11 |
3 files changed, 15 insertions, 8 deletions
diff --git a/src/flam3-animate.c b/src/flam3-animate.c index 7f00676..402e3ee 100644 --- a/src/flam3-animate.c +++ b/src/flam3-animate.c @@ -213,9 +213,9 @@ int main(int argc, char **argv) { f.bytes_per_channel = 1; - image = (void *) malloc((size_t)channels * + image = (void *) calloc((size_t)channels * (size_t)cps[0].width * - (size_t)cps[0].height * f.bytes_per_channel); + (size_t)cps[0].height * f.bytes_per_channel, sizeof(char)); if (dtime < 1) { fprintf(stderr, "dtime must be positive, not %d.\n", dtime); diff --git a/src/flam3-render.c b/src/flam3-render.c index 11b69cf..7273fdb 100644 --- a/src/flam3-render.c +++ b/src/flam3-render.c @@ -295,7 +295,7 @@ int main(int argc, char **argv) { if (last_size != -1) free(image); last_size = this_size; - image = (void *) malloc(this_size); + image = (void *) calloc(this_size, sizeof(char)); if (NULL==image) { fprintf(stderr,"Error allocating memory for image. Aborting\n"); exit(1); @@ -351,7 +351,7 @@ int main(int argc, char **argv) { sprintf(fname, "%s%05d.%s", prefix, i, format); } if (verbose) { - fprintf(stderr, "writing %s...", fname); + fprintf(stderr, "writing %s...", fname); } fp = fopen(fname, "wb"); if (NULL == fp) { @@ -381,8 +381,8 @@ int main(int argc, char **argv) { fprintf(fp, "P6\n"); fprintf(fp, "%d %d\n255\n", cps[i].width, real_height); if (this_size != fwrite((unsigned char *)image, 1, this_size, fp)) { - perror(fname); - } + perror(fname); + } } /* Free string */ free(fpc.genome); @@ -106,8 +106,6 @@ void write_png(FILE *file, void *image, int width, int height, flam3_img_comment im[i] = htons(im[i]); } } - - if (pngcom_enable==1) png_set_text(png_ptr, info_ptr, text, FLAM3_PNG_COM); @@ -117,6 +115,15 @@ void write_png(FILE *file, void *image, int width, int height, flam3_img_comment png_write_end(png_ptr, info_ptr); png_destroy_write_struct(&png_ptr, &info_ptr); free(rows); + + /* Swap back the bytes in case we're doing strips */ + if (2==bpc && testbe != htons(testbe)) { + unsigned short *im = (unsigned short *)image; + for (i=0; i<height*width*4; i++) { + im[i] = htons(im[i]); + } + } + } #define SIG_CHECK_SIZE 8 |