Skip to content

Commit c0b5f48

Browse files
committed
Fix: BLOAD was silently misreading bitfields for BMPs with the undocumented BITMAPV3HEADER format (56-byte) headers.
It was treating them the same as the older 24-byte header, which placed the bitfield values after the header (where the colour table is), so was looking for them after the header.
1 parent 7b7aeb3 commit c0b5f48

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ Version 1.01.0
5454
- DRAW was not unsetting the B/N qualifiers after 0-length directional commands, e.g. "R0", resulting in them being applied to the following command, e.g. DRAW "B U0D0L0R0 R10" would not draw "R10"
5555
- Bad code was generated when initializing integer variables with a wstring-indexing expressions
5656
- #723: LINE clipping now doesn't affect which (unclipped) pixels are plotted, eliminating rounding differences and correctly preserving the position of the style bits
57+
- BLOAD was silently misreading bitfields for BMPs with BITMAPV3HEADER format (56-byte) headers
5758

5859

5960
Version 1.00.0 (former 0.91.0):

src/gfxlib2/gfx_bload.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ static int load_bmp(FB_GFXCTX *ctx, FILE *f, void *dest, void *pal, int usenewhe
227227
return FB_RTERROR_FILEIO;
228228
}
229229

230-
if (biSize >= 108) {
231-
/* Windows V4 (BITMAPV4HEADER) or later */
230+
if (biSize >= 56) {
231+
/* Windows V3 (BITMAPV3HEADER) or later */
232232
if ((fseek(f, 4*4, SEEK_CUR)) ||
233233
(!fread_32_le(&rgba[0], f)) ||
234234
(!fread_32_le(&rgba[1], f)) ||
@@ -329,7 +329,7 @@ static int load_bmp(FB_GFXCTX *ctx, FILE *f, void *dest, void *pal, int usenewhe
329329

330330
expand = (biBitCount < 8) ? biBitCount : 0;
331331
if (biCompression == BI_BITFIELDS) {
332-
if (biSize < 108) {
332+
if (biSize < 56) {
333333
if (!fread(rgba, 12, 1, f))
334334
return FB_RTERROR_FILEIO;
335335
}

0 commit comments

Comments
 (0)