Supports various bitmap headers

This commit is contained in:
abcang 2019-09-05 14:40:25 +09:00
parent 18831de7de
commit 6f548c5509
4 changed files with 5 additions and 3 deletions

View File

@ -580,10 +580,10 @@ class FastImage
d = @stream.read(32)[14..28]
header = d.unpack("C")[0]
result = if header == 40
d[4..-1].unpack('l<l<')
else
result = if header == 12
d[4..8].unpack('SS')
else
d[4..-1].unpack('l<l<')
end
# ImageHeight is expressed in pixels. The absolute value is necessary because ImageHeight can be negative

BIN
test/fixtures/test_coreheader.bmp vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
test/fixtures/test_v5header.bmp vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -11,6 +11,8 @@ FixturePath = File.join(PathHere, "fixtures")
GoodFixtures = {
"test.bmp"=>[:bmp, [40, 27]],
"test2.bmp"=>[:bmp, [1920, 1080]],
"test_coreheader.bmp"=>[:bmp, [40, 27]],
"test_v5header.bmp"=>[:bmp, [40, 27]],
"test.gif"=>[:gif, [17, 32]],
"test.jpg"=>[:jpeg, [882, 470]],
"test.png"=>[:png, [30, 20]],