libgd icon indicating copy to clipboard operation
libgd copied to clipboard

Fix BMP header size

Open cmb69 opened this issue 1 year ago • 3 comments

The bfSize member of BITMAPFILEHEADER is supposed to store the size of the BMP[1], and as such needs to be equal to the file size (for BMPs stored as files). Otherwise that may trip up readers; at least they may assume that the BMP is corrupted; e.g. ImageMagick warns about this.

While for compressed BMP images we actually calculate the size as we go, for uncompressed BMP images we calculate the size in advance, but so far did not account for padding of the rows.

We also fix the biSizeImage of the BITMAPINFOHEADER[2] accordingly.

[1] https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapfileheader [2] https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapinfoheader

cmb69 avatar Dec 24 '24 14:12 cmb69

Ubuntu and macOS CI failures are unrelated.

cmb69 avatar Dec 24 '24 14:12 cmb69

The CI failures are unrelated again (note that there are occassional segfaults on MinGW for different tests; that might justify some further investigation).

cmb69 avatar Dec 25 '24 13:12 cmb69

Rebased and force-pushed to get CI green (at least Ubuntu should be fixed in the meantime).

cmb69 avatar Jan 01 '25 23:01 cmb69