[Image-SIG] Patch for BmpImagePlugin
Rob Hooft
R.Hooft@EuroMail.com
Thu, 24 Sep 1998 11:34:13 +0200 (MZT)
Here is a patch that makes PIL read Bmp images made by Windows, where the
number of colors is smaller than the maximum for the number of bits per
pixel (I have an 8bit image here that uses a 32 color palette).
*** /usr/people/hooft/p/basis4/Imaging-0.3b2/PIL/BmpImagePlugin.py Sun Jul 19 16:25:14 1998
--- ./BmpImagePlugin.py Thu Sep 24 11:19:04 1998
***************
*** 70,75 ****
--- 70,76 ----
bits = i16(s[10:])
self.size = i16(s[4:]), i16(s[6:])
lutsize = 3
+ colors=1 << bits
elif len(s) in [40, 64]:
***************
*** 77,82 ****
--- 78,86 ----
bits = i16(s[14:])
self.size = i32(s[4:]), i32(s[8:])
self.info["compression"] = i32(s[16:])
+ colors=i32(s[32:])
+ if colors==0:
+ colors=1 << bits
lutsize = 4
else:
***************
*** 90,96 ****
# LUT
if self.mode == "P":
- colors = 1 << bits
palette = []
greyscale = 1
if colors == 2:
--- 94,99 ----