mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-24 14:14:47 +03:00
GIF: Handle GIF transparency in the decoder.
Remove the special case for disposal_method == 1 and handle GIF transparency by telling the decoder the transparent index.
This commit is contained in:
parent
35c6ebd750
commit
68b844de74
|
@ -141,7 +141,6 @@ class GifImageFile(ImageFile.ImageFile):
|
||||||
self.dispose_extent = [0, 0, 0, 0] # x0, y0, x1, y1
|
self.dispose_extent = [0, 0, 0, 0] # x0, y0, x1, y1
|
||||||
self.__frame = -1
|
self.__frame = -1
|
||||||
self.__fp.seek(self.__rewind)
|
self.__fp.seek(self.__rewind)
|
||||||
self._prev_im = None
|
|
||||||
self.disposal_method = 0
|
self.disposal_method = 0
|
||||||
else:
|
else:
|
||||||
# ensure that the previous frame was loaded
|
# ensure that the previous frame was loaded
|
||||||
|
@ -247,7 +246,7 @@ class GifImageFile(ImageFile.ImageFile):
|
||||||
self.tile = [("gif",
|
self.tile = [("gif",
|
||||||
(x0, y0, x1, y1),
|
(x0, y0, x1, y1),
|
||||||
self.__offset,
|
self.__offset,
|
||||||
(bits, interlace, -1))]
|
(bits, interlace, info.get("transparency", -1)))]
|
||||||
break
|
break
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
@ -290,20 +289,6 @@ class GifImageFile(ImageFile.ImageFile):
|
||||||
def tell(self):
|
def tell(self):
|
||||||
return self.__frame
|
return self.__frame
|
||||||
|
|
||||||
def load_end(self):
|
|
||||||
ImageFile.ImageFile.load_end(self)
|
|
||||||
|
|
||||||
# if the disposal method is 'do not dispose', transparent
|
|
||||||
# pixels should show the content of the previous frame
|
|
||||||
if self._prev_im and self.disposal_method == 1:
|
|
||||||
# we do this by pasting the updated area onto the previous
|
|
||||||
# frame which we then use as the current image content
|
|
||||||
updated = self._crop(self.im, self.dispose_extent)
|
|
||||||
self._prev_im.paste(updated, self.dispose_extent,
|
|
||||||
updated.convert('RGBA'))
|
|
||||||
self.im = self._prev_im
|
|
||||||
self._prev_im = self.im.copy()
|
|
||||||
|
|
||||||
def _close__fp(self):
|
def _close__fp(self):
|
||||||
try:
|
try:
|
||||||
if self.__fp != self.fp:
|
if self.__fp != self.fp:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user