pr feedback

This commit is contained in:
Adam Panzer 2014-10-22 08:40:24 -07:00
parent b7aa051e8f
commit 18d0908eeb
3 changed files with 5 additions and 3 deletions

View File

@ -379,8 +379,7 @@ class FastImage
:psd
when "\0\0"
# ico has either a 1 (for ico format) or 2 (for cursor) at offset 3
format = @stream.peek(3)
format == [0,0,1].pack('c*') ? :ico : (format == [0,0,10].pack('c*') ? :cur : nil)
{1 => :ico, 2 => :cur}[@stream.peek(3)[2].unpack('C')[0]]
else
raise UnknownImageType
end
@ -389,6 +388,7 @@ class FastImage
def parse_size_for_ico
@stream.read(8)[6..7].unpack('CC').map{|byte| byte == 0 ? 256 : byte }
end
alias_method :parse_size_for_cur, :parse_size_for_ico
def parse_size_for_gif
@stream.read(11)[6..10].unpack('SS')

BIN
test/fixtures/test.cur vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -26,7 +26,8 @@ GoodFixtures = {
"infinite.jpg"=>[:jpeg, [160,240]],
"orient_2.jpg"=>[:jpeg, [230,408]],
"favicon.ico" => [:ico, [16, 16]],
"man.ico" => [:ico, [48, 48]]
"man.ico" => [:ico, [48, 48]],
"test.cur" => [:cur, [32, 32]]
}
BadFixtures = [
@ -35,6 +36,7 @@ BadFixtures = [
]
# man.ico courtesy of http://www.iconseeker.com/search-icon/artists-valley-sample/business-man-blue.html
# test_rgb.ct courtesy of http://fileformats.archiveteam.org/wiki/Scitex_CT
# test.cur courtesy of http://mimidestino.deviantart.com/art/Clash-Of-Clans-Dragon-Cursor-s-Punteros-489070897
TestUrl = "http://example.nowhere/"