70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/zpng/bmp/reader.rb', line 70
def _read_bmp io
filesize, reserved1, reserved2, imagedata_offset = io.read(4+2+2+4).unpack('VvvV')
hdr = BITMAPINFOHEADER.read(io)
if hdr.biSize != BITMAPINFOHEADER::SIZE
raise "dib_hdr_size #{hdr.biSize} unsupported, want #{BITMAPINFOHEADER::SIZE}"
end
@new_image = true
@color_class = BMP::Color
@format = :bmp
@chunks << BmpHdrPseudoChunk.new(hdr)
row_size = ((hdr.biBitCount*self.width+31)/32)*4
io.seek(imagedata_offset)
@scanlines = []
self.height.times do |idx|
offset = io.tell - imagedata_offset
data = io.read(row_size)
@scanlines.unshift ScanLine.new(self, self.height-idx-1,
:decoded_bytes => data,
:size => row_size,
:offset => offset
)
end
extend ImageMixin
end
|