Commit 64822a06 authored by Augusto Fraga Giachero's avatar Augusto Fraga Giachero Committed by Davis E. King

Ignore bmp reserved area (#1343)

The 4 bytes starting from the 0x06 offset of a bmp file are marked as
'Reserved' but it doesn't guarantee that these bytes are zeroed, some
applications uses this area for its own purposes and the output file
still a valid bmp file.
parent 490754b3
......@@ -41,7 +41,6 @@ namespace dlib
unsigned long bytes_read_so_far = 0;
unsigned long bfSize;
unsigned long bfOffBits;
unsigned long bfReserved;
unsigned long biSize;
unsigned long biWidth;
int32 biHeight;
......@@ -79,20 +78,12 @@ namespace dlib
a = buf[i]; b = buf[i+1]; c = buf[i+2]; d = buf[i+3];
bfSize = a | (b<<8) | (c<<16) | (d<<24);
i = 4;
a = buf[i]; b = buf[i+1]; c = buf[i+2]; d = buf[i+3];
bfReserved = a | (b<<8) | (c<<16) | (d<<24);
// Ignore the next 4 bytes (Reserved Area)
i = 8;
a = buf[i]; b = buf[i+1]; c = buf[i+2]; d = buf[i+3];
bfOffBits = a | (b<<8) | (c<<16) | (d<<24);
// if this value isn't zero then there is something wrong
// with this bitmap.
if (bfReserved != 0)
throw image_load_error("bmp load error 4: reserved area not zero");
// load the BITMAPINFOHEADER
if (in.sgetn(reinterpret_cast<char*>(buf),40) != 40)
throw image_load_error("bmp load error 5: file too short");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment