mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-22 14:50:33 +03:00
fixed bug regarding bitmap (added alpha flag)
This commit is contained in:
parent
8aa0a864fe
commit
915df6c7cf
|
@ -58,13 +58,15 @@ def _save_frame(im: Image.Image, fp: BytesIO, filename: str, info: dict):
|
|||
|
||||
image_io = BytesIO()
|
||||
if bmp:
|
||||
frame.save(image_io, "dib")
|
||||
|
||||
if bits != 32:
|
||||
and_mask = Image.new("1", size)
|
||||
ImageFile._save(
|
||||
and_mask, image_io, [("raw", (0, 0) + size, 0, ("1", 0, -1))]
|
||||
)
|
||||
else:
|
||||
frame.alpha = True
|
||||
|
||||
frame.save(image_io, "dib")
|
||||
else:
|
||||
frame.save(image_io, "png")
|
||||
image_io.seek(0)
|
||||
|
|
|
@ -209,8 +209,11 @@ class BmpImageFile(ImageFile.ImageFile):
|
|||
else:
|
||||
raise OSError("Unsupported BMP bitfields layout")
|
||||
elif file_info["compression"] == self.RAW:
|
||||
if file_info["bits"] == 32: # 32-bit has transparency
|
||||
raw_mode, self.mode = "BGRA", "RGBA"
|
||||
try:
|
||||
if file_info["bits"] == 32 and self.alpha:
|
||||
raw_mode, self.mode = "BGRA", "RGBA"
|
||||
except AttributeError:
|
||||
pass
|
||||
elif file_info["compression"] == self.RLE8:
|
||||
decoder_name = "bmp_rle"
|
||||
else:
|
||||
|
|
|
@ -76,13 +76,15 @@ def _save(im: Image.Image, fp: BytesIO, filename: str):
|
|||
|
||||
image_io = BytesIO()
|
||||
if bmp:
|
||||
frame.save(image_io, "dib")
|
||||
|
||||
if bits != 32:
|
||||
and_mask = Image.new("1", size)
|
||||
ImageFile._save(
|
||||
and_mask, image_io, [("raw", (0, 0) + size, 0, ("1", 0, -1))]
|
||||
)
|
||||
else:
|
||||
frame.alpha = True
|
||||
|
||||
frame.save(image_io, "dib")
|
||||
else:
|
||||
frame.save(image_io, "png")
|
||||
image_io.seek(0)
|
||||
|
|
Loading…
Reference in New Issue
Block a user