mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-09 16:10:48 +03:00
Consider I;16 pixel size when drawing text
This commit is contained in:
parent
be30792714
commit
a39cb04f3e
|
@ -134,6 +134,17 @@ class TestImageFont:
|
||||||
target = "Tests/images/transparent_background_text_L.png"
|
target = "Tests/images/transparent_background_text_L.png"
|
||||||
assert_image_similar_tofile(im.convert("L"), target, 0.01)
|
assert_image_similar_tofile(im.convert("L"), target, 0.01)
|
||||||
|
|
||||||
|
def test_I16(self):
|
||||||
|
im = Image.new(mode="I;16", size=(300, 100))
|
||||||
|
draw = ImageDraw.Draw(im)
|
||||||
|
ttf = self.get_font()
|
||||||
|
|
||||||
|
txt = "Hello World!"
|
||||||
|
draw.text((10, 10), txt, font=ttf)
|
||||||
|
|
||||||
|
target = "Tests/images/transparent_background_text_L.png"
|
||||||
|
assert_image_similar_tofile(im.convert("L"), target, 0.01)
|
||||||
|
|
||||||
def test_textsize_equal(self):
|
def test_textsize_equal(self):
|
||||||
im = Image.new(mode="RGB", size=(300, 100))
|
im = Image.new(mode="RGB", size=(300, 100))
|
||||||
draw = ImageDraw.Draw(im)
|
draw = ImageDraw.Draw(im)
|
||||||
|
|
|
@ -417,9 +417,16 @@ fill_mask_L(
|
||||||
if (imOut->image8) {
|
if (imOut->image8) {
|
||||||
for (y = 0; y < ysize; y++) {
|
for (y = 0; y < ysize; y++) {
|
||||||
UINT8 *out = imOut->image8[y + dy] + dx;
|
UINT8 *out = imOut->image8[y + dy] + dx;
|
||||||
|
if (strncmp(imOut->mode, "I;16", 4) == 0) {
|
||||||
|
out += dx;
|
||||||
|
}
|
||||||
UINT8 *mask = imMask->image8[y + sy] + sx;
|
UINT8 *mask = imMask->image8[y + sy] + sx;
|
||||||
for (x = 0; x < xsize; x++) {
|
for (x = 0; x < xsize; x++) {
|
||||||
*out = BLEND(*mask, *out, ink[0], tmp1);
|
*out = BLEND(*mask, *out, ink[0], tmp1);
|
||||||
|
if (strncmp(imOut->mode, "I;16", 4) == 0) {
|
||||||
|
out++;
|
||||||
|
*out = BLEND(*mask, *out, ink[0], tmp1);
|
||||||
|
}
|
||||||
out++, mask++;
|
out++, mask++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user