Comments for future people investigating alpha and DIBs

This commit is contained in:
wiredfool 2016-04-19 20:26:16 +01:00
parent 23a847c532
commit 0507192a77
2 changed files with 5 additions and 2 deletions

View File

@ -112,7 +112,9 @@ class BmpImageFile(ImageFile.ImageFile):
# 40 byte headers only have the three components in the bitfields masks,
# ref: https://msdn.microsoft.com/en-us/library/windows/desktop/dd183376(v=vs.85).aspx
# See also https://github.com/python-pillow/Pillow/issues/1293
file_info['a_mask'] = 0xff000000
# There is a 4th component in the RGBQuad, in the alpha location, but it
# is listed as a reserved component, and it is not generally an alpha channel
file_info['a_mask'] = 0x0
for mask in ['r_mask', 'g_mask', 'b_mask']:
file_info[mask] = i32(read(4))
file_info['rgb_mask'] = (file_info['r_mask'], file_info['g_mask'], file_info['b_mask'])

View File

@ -74,8 +74,9 @@ class TestFileBmp(PillowTestCase):
# test for #1293, Imagegrab returning Unsupported Bitfields Format
im = BmpImagePlugin.DibImageFile('Tests/images/clipboard.dib')
target = Image.open('Tests/images/clipboard_target.png')
# test only the RGB components, as there is no alpha in the DIB file.
self.assert_image_equal(im.convert('RGB'), target.convert('RGB'))
self.assert_image_similar(im, target, 1)
if __name__ == '__main__':