mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 10:46:16 +03:00
Remember correct image offset if bitfields+palette
Use the provided image offset if there is palette data while the image is bitfielded.
This commit is contained in:
parent
877c138e21
commit
497ddf9c68
|
@ -85,8 +85,10 @@ class BmpImageFile(ImageFile.ImageFile):
|
|||
""" Read relevant info about the BMP """
|
||||
read, seek = self.fp.read, self.fp.seek
|
||||
seek(2)
|
||||
start_data = read(12)
|
||||
file_info = dict()
|
||||
file_info['filesize'] = i32(read(12)[0:4]) # file size @offset 2 (offsets 4, 12 are reserved for OS/2 Icons)
|
||||
file_info['filesize'] = i32(start_data[0:4]) # file size @offset 2 (offsets 4, 12 are reserved for OS/2 Icons)
|
||||
file_info['image_offset'] = i32(start_data[8:12]) # file size @offset 2 (offsets 4, 12 are reserved for OS/2 Icons)
|
||||
file_info['header_size'] = i32(read(4)) # read bmp header size @offset 14 (this is part of the header size)
|
||||
file_info['direction'] = -1
|
||||
header_data = ImageFile._safe_read(self.fp, file_info['header_size'] - 4) # read the rest of the bmp header, without its size
|
||||
|
@ -101,7 +103,7 @@ class BmpImageFile(ImageFile.ImageFile):
|
|||
file_info['compression'] = self.RAW
|
||||
file_info['palette_padding'] = 3
|
||||
#----------------------------------------------- Windows Bitmap v2 to v5
|
||||
elif file_info['header_size'] in {40, 64, 108, 124}: # v3, OS/2 v2, v4, v5
|
||||
elif file_info['header_size'] in (40, 64, 108, 124): # v3, OS/2 v2, v4, v5
|
||||
if file_info['header_size'] >= 64:
|
||||
file_info['r_mask'] = i32(header_data[36:40])
|
||||
file_info['g_mask'] = i32(header_data[40:44])
|
||||
|
|
Loading…
Reference in New Issue
Block a user