mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Apply transparency to P images before passing to tkinter.PhotoImage
This commit is contained in:
parent
b6348d9b2d
commit
ee5de25f87
|
@ -69,6 +69,13 @@ def test_photoimage():
|
||||||
assert_image_equal(reloaded, im.convert("RGBA"))
|
assert_image_equal(reloaded, im.convert("RGBA"))
|
||||||
|
|
||||||
|
|
||||||
|
def test_photoimage_apply_transparency():
|
||||||
|
with Image.open("Tests/images/pil123p.png") as im:
|
||||||
|
im_tk = ImageTk.PhotoImage(im)
|
||||||
|
reloaded = ImageTk.getimage(im_tk)
|
||||||
|
assert_image_equal(reloaded, im.convert("RGBA"))
|
||||||
|
|
||||||
|
|
||||||
def test_photoimage_blank():
|
def test_photoimage_blank():
|
||||||
# test a image using mode/size:
|
# test a image using mode/size:
|
||||||
for mode in TK_MODES:
|
for mode in TK_MODES:
|
||||||
|
|
|
@ -107,6 +107,7 @@ class PhotoImage:
|
||||||
mode = image.mode
|
mode = image.mode
|
||||||
if mode == "P":
|
if mode == "P":
|
||||||
# palette mapped data
|
# palette mapped data
|
||||||
|
image.apply_transparency()
|
||||||
image.load()
|
image.load()
|
||||||
try:
|
try:
|
||||||
mode = image.palette.mode
|
mode = image.palette.mode
|
||||||
|
|
Loading…
Reference in New Issue
Block a user