mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Do not alter pixels outside mask when drawing text on an image with transparency
This commit is contained in:
parent
ef9a8e5f7f
commit
8bc19ac78c
Binary file not shown.
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.3 KiB |
BIN
Tests/images/transparent_background_text_L.png
Normal file
BIN
Tests/images/transparent_background_text_L.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 350 B |
|
@ -236,7 +236,7 @@ class TestImagingPaste:
|
|||
[
|
||||
(127, 191, 254, 191),
|
||||
(111, 207, 206, 110),
|
||||
(255, 255, 255, 0) if mode == "RGBA" else (127, 254, 127, 0),
|
||||
(127, 254, 127, 0),
|
||||
(207, 207, 239, 239),
|
||||
(191, 191, 190, 191),
|
||||
(207, 206, 111, 112),
|
||||
|
|
|
@ -131,6 +131,9 @@ class TestImageFont:
|
|||
target = "Tests/images/transparent_background_text.png"
|
||||
assert_image_similar_tofile(im, target, 4.09)
|
||||
|
||||
target = "Tests/images/transparent_background_text_L.png"
|
||||
assert_image_similar_tofile(im.convert("L"), target, 0.01)
|
||||
|
||||
def test_textsize_equal(self):
|
||||
im = Image.new(mode="RGB", size=(300, 100))
|
||||
draw = ImageDraw.Draw(im)
|
||||
|
|
|
@ -436,7 +436,7 @@ fill_mask_L(
|
|||
strcmp(imOut->mode, "La") == 0 ||
|
||||
strcmp(imOut->mode, "LA") == 0 ||
|
||||
strcmp(imOut->mode, "PA") == 0) &&
|
||||
i != 3) {
|
||||
i != 3 && channel_mask != 0) {
|
||||
channel_mask =
|
||||
255 - (255 - channel_mask) * (1 - (255 - out[3]) / 255);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user