mirror of https://github.com/adamdruppe/arsd.git
skip unknown data in bmp between header and data
This commit is contained in:
parent
f4eb75a1d9
commit
93fb163d73
17
bmp.d
17
bmp.d
|
|
@ -112,6 +112,9 @@ MemoryImage readBmpIndirect(scope void delegate(void*, size_t) fread, bool lookF
|
|||
throw new Exception("didn't get expected int value " /*~ to!string(got)*/, __FILE__, line);
|
||||
}
|
||||
|
||||
uint offsetToBits;
|
||||
int offsetToBitsAfterHeader;
|
||||
|
||||
if(lookForFileHeader) {
|
||||
require1('B');
|
||||
require1('M');
|
||||
|
|
@ -120,7 +123,7 @@ MemoryImage readBmpIndirect(scope void delegate(void*, size_t) fread, bool lookF
|
|||
require2(0); // reserved
|
||||
require2(0); // reserved
|
||||
|
||||
auto offsetToBits = read4();
|
||||
offsetToBits = read4();
|
||||
version(arsd_debug_bitmap_loader) { import core.stdc.stdio; printf("pixel data offset: 0x%08x\n", cast(uint)offsetToBits); }
|
||||
}
|
||||
|
||||
|
|
@ -129,6 +132,9 @@ MemoryImage readBmpIndirect(scope void delegate(void*, size_t) fread, bool lookF
|
|||
|
||||
version(arsd_debug_bitmap_loader) { import core.stdc.stdio; printf("size of bitmap info header: %d\n", cast(uint)sizeOfBitmapInfoHeader); }
|
||||
|
||||
if(offsetToBits > sizeOfBitmapInfoHeader + 14 /* 14 is the size size of file header */)
|
||||
offsetToBitsAfterHeader = offsetToBits - sizeOfBitmapInfoHeader - 14;
|
||||
|
||||
int width, height, rdheight;
|
||||
|
||||
if (sizeOfBitmapInfoHeader == 12) {
|
||||
|
|
@ -425,12 +431,9 @@ MemoryImage readBmpIndirect(scope void delegate(void*, size_t) fread, bool lookF
|
|||
// true color image
|
||||
auto img = new TrueColorImage(width, height);
|
||||
|
||||
if(compression == 3)
|
||||
foreach(idx; 0 .. 3) {
|
||||
// so tbh I don't know what this actually is, it looks like an rgb mask, but why is it here?
|
||||
// is this common or just the one file i happen to have?
|
||||
// is there some header byte im missing?
|
||||
read4();
|
||||
foreach(counter; 0 .. offsetToBitsAfterHeader) {
|
||||
// so tbh I don't know what this actually is, but we can know to skip it at least
|
||||
read1();
|
||||
}
|
||||
|
||||
// no palette, so straight into the data
|
||||
|
|
|
|||
Loading…
Reference in New Issue