16 bpc PNG images were not being written properly when strips were being used. while png_set_swap() is supposed to tell the system to reverse the order of the bits when writing the file, I was unable to get this to work, so I resorted to a brute-force reversal of the bits - but then forgot to put the bits BACK. This is not a problem for single strips, but with multiple strips things get very confused. png_set_swap would make this a non-issue.

git-svn-id: https://flam3.googlecode.com/svn/trunk@88 77852712-ef1d-11de-8684-7d64432d61a3
This commit is contained in:
Erik Reckase 2010-11-21 02:05:12 +00:00 committed by Scott Draves
parent 26f5c53f09
commit b358966b64
3 changed files with 15 additions and 8 deletions

View File

@ -213,9 +213,9 @@ int main(int argc, char **argv) {
f.bytes_per_channel = 1; 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].width *
(size_t)cps[0].height * f.bytes_per_channel); (size_t)cps[0].height * f.bytes_per_channel, sizeof(char));
if (dtime < 1) { if (dtime < 1) {
fprintf(stderr, "dtime must be positive, not %d.\n", dtime); fprintf(stderr, "dtime must be positive, not %d.\n", dtime);

View File

@ -295,7 +295,7 @@ int main(int argc, char **argv) {
if (last_size != -1) if (last_size != -1)
free(image); free(image);
last_size = this_size; last_size = this_size;
image = (void *) malloc(this_size); image = (void *) calloc(this_size, sizeof(char));
if (NULL==image) { if (NULL==image) {
fprintf(stderr,"Error allocating memory for image. Aborting\n"); fprintf(stderr,"Error allocating memory for image. Aborting\n");
exit(1); exit(1);

View File

@ -107,8 +107,6 @@ void write_png(FILE *file, void *image, int width, int height, flam3_img_comment
} }
} }
if (pngcom_enable==1) if (pngcom_enable==1)
png_set_text(png_ptr, info_ptr, text, FLAM3_PNG_COM); 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_write_end(png_ptr, info_ptr);
png_destroy_write_struct(&png_ptr, &info_ptr); png_destroy_write_struct(&png_ptr, &info_ptr);
free(rows); 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 #define SIG_CHECK_SIZE 8