mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-23 15:20: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()
|
image_io = BytesIO()
|
||||||
if bmp:
|
if bmp:
|
||||||
frame.save(image_io, "dib")
|
|
||||||
|
|
||||||
if bits != 32:
|
if bits != 32:
|
||||||
and_mask = Image.new("1", size)
|
and_mask = Image.new("1", size)
|
||||||
ImageFile._save(
|
ImageFile._save(
|
||||||
and_mask, image_io, [("raw", (0, 0) + size, 0, ("1", 0, -1))]
|
and_mask, image_io, [("raw", (0, 0) + size, 0, ("1", 0, -1))]
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
frame.alpha = True
|
||||||
|
|
||||||
|
frame.save(image_io, "dib")
|
||||||
else:
|
else:
|
||||||
frame.save(image_io, "png")
|
frame.save(image_io, "png")
|
||||||
image_io.seek(0)
|
image_io.seek(0)
|
||||||
|
|
|
@ -209,8 +209,11 @@ class BmpImageFile(ImageFile.ImageFile):
|
||||||
else:
|
else:
|
||||||
raise OSError("Unsupported BMP bitfields layout")
|
raise OSError("Unsupported BMP bitfields layout")
|
||||||
elif file_info["compression"] == self.RAW:
|
elif file_info["compression"] == self.RAW:
|
||||||
if file_info["bits"] == 32: # 32-bit has transparency
|
try:
|
||||||
|
if file_info["bits"] == 32 and self.alpha:
|
||||||
raw_mode, self.mode = "BGRA", "RGBA"
|
raw_mode, self.mode = "BGRA", "RGBA"
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
elif file_info["compression"] == self.RLE8:
|
elif file_info["compression"] == self.RLE8:
|
||||||
decoder_name = "bmp_rle"
|
decoder_name = "bmp_rle"
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -76,13 +76,15 @@ def _save(im: Image.Image, fp: BytesIO, filename: str):
|
||||||
|
|
||||||
image_io = BytesIO()
|
image_io = BytesIO()
|
||||||
if bmp:
|
if bmp:
|
||||||
frame.save(image_io, "dib")
|
|
||||||
|
|
||||||
if bits != 32:
|
if bits != 32:
|
||||||
and_mask = Image.new("1", size)
|
and_mask = Image.new("1", size)
|
||||||
ImageFile._save(
|
ImageFile._save(
|
||||||
and_mask, image_io, [("raw", (0, 0) + size, 0, ("1", 0, -1))]
|
and_mask, image_io, [("raw", (0, 0) + size, 0, ("1", 0, -1))]
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
frame.alpha = True
|
||||||
|
|
||||||
|
frame.save(image_io, "dib")
|
||||||
else:
|
else:
|
||||||
frame.save(image_io, "png")
|
frame.save(image_io, "png")
|
||||||
image_io.seek(0)
|
image_io.seek(0)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user