Fix PNG height

Fixed array index where to store image height.
PNG files made using `tdefl_write_image_to_png_file_in_memory_ex()` were very tall, with a huge empty area at the end.
Since `pnghdr[22]` was assigned twice, I changed indices to store height exactly in the way width is stored (two consecutive swapped bytes). Now PNG file height is correct.
This commit is contained in:
Mario Cianciolo
2017-04-30 23:13:09 +02:00
committed by GitHub
parent 9b1ddf6861
commit a0786b126d

View File

@@ -1490,7 +1490,7 @@ void *tdefl_write_image_to_png_file_in_memory_ex(const void *pImage, int w, int
pnghdr[18] = (mz_uint8)(w >> 8); pnghdr[18] = (mz_uint8)(w >> 8);
pnghdr[19] = (mz_uint8)w; pnghdr[19] = (mz_uint8)w;
pnghdr[22] = (mz_uint8)(h >> 8); pnghdr[22] = (mz_uint8)(h >> 8);
pnghdr[22] = (mz_uint8)h; pnghdr[23] = (mz_uint8)h;
pnghdr[25] = chans[num_chans]; pnghdr[25] = chans[num_chans];
pnghdr[33] = (mz_uint8)(*pLen_out >> 24); pnghdr[33] = (mz_uint8)(*pLen_out >> 24);
pnghdr[34] = (mz_uint8)(*pLen_out >> 16); pnghdr[34] = (mz_uint8)(*pLen_out >> 16);