lvandeve / lodepng

PNG encoder and decoder in C and C++.
zlib License
2.11k stars 426 forks source link

RGB to PNG wrong alignment? #154

Closed avafinger closed 2 years ago

avafinger commented 2 years ago

Hi @lvandeve , thanks for your work. I am trying to convert the data portion of a windows bitmap to png but it fails when (h % 4 ) > 0. There seems some alignment issue, I could not figure out.

The environment and compiler are Windows and Visual C, 32 bit. Perhaps I should force some alignment during compilation, can you suggest a possible fix or where I should look for in order to fix this?

Attached are the results of a successful conversion (264x264) and a failed one (198x198).

avafinger commented 2 years ago

FYI, the bmp header info is not filled up completely, you must assume the size, but there is something wrong with the padding.

avafinger commented 2 years ago

Tested on Linux x64, same problem. So, lodepng_encode24_file(szbuf, data, bmInfoHeader->biWidth, bmInfoHeader->biHeight); does not consider padding.

avafinger commented 2 years ago

passing data without the padding worked.