mirror of
https://github.com/scottdraves/flam3.git
synced 2025-01-20 21:10:08 -05:00
png_set_swap must be called after the png_write_info call, otherwise it doesn't work. Would have been nice if this was documented a bit better. No more brute force byte swapping!
git-svn-id: https://flam3.googlecode.com/svn/trunk@90 77852712-ef1d-11de-8684-7d64432d61a3
This commit is contained in:
parent
a327e855a9
commit
ba1a8451bf
22
src/png.c
22
src/png.c
@ -99,31 +99,21 @@ void write_png(FILE *file, void *image, int width, int height, flam3_img_comment
|
||||
PNG_COMPRESSION_TYPE_BASE,
|
||||
PNG_FILTER_TYPE_BASE);
|
||||
|
||||
/* Swap the bytes if we're doing 16bpc and on little-endian platform */
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
if (pngcom_enable==1)
|
||||
png_set_text(png_ptr, info_ptr, text, FLAM3_PNG_COM);
|
||||
|
||||
png_write_info(png_ptr, info_ptr);
|
||||
|
||||
/* Must set this after the write_info */
|
||||
if (2==bpc && testbe != htons(testbe)) {
|
||||
png_set_swap(png_ptr);
|
||||
}
|
||||
|
||||
png_write_image(png_ptr, (png_bytepp) rows);
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user