mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Corrected using a 1 mode mask with I;16* images
This commit is contained in:
parent
0fbc3db081
commit
08b5a2e9a7
BIN
Tests/images/imagedraw_polygon_width_I.tiff
Normal file
BIN
Tests/images/imagedraw_polygon_width_I.tiff
Normal file
Binary file not shown.
|
@ -631,6 +631,19 @@ def test_polygon(points: Coords) -> None:
|
||||||
assert_image_equal_tofile(im, "Tests/images/imagedraw_polygon.png")
|
assert_image_equal_tofile(im, "Tests/images/imagedraw_polygon.png")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("points", POINTS)
|
||||||
|
def test_polygon_width_I16(points: Coords) -> None:
|
||||||
|
# Arrange
|
||||||
|
im = Image.new("I;16", (W, H))
|
||||||
|
draw = ImageDraw.Draw(im)
|
||||||
|
|
||||||
|
# Act
|
||||||
|
draw.polygon(points, outline=0xFFFF, width=2)
|
||||||
|
|
||||||
|
# Assert
|
||||||
|
assert_image_equal_tofile(im, "Tests/images/imagedraw_polygon_width_I.tiff")
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("mode", ("RGB", "L"))
|
@pytest.mark.parametrize("mode", ("RGB", "L"))
|
||||||
@pytest.mark.parametrize("kite_points", KITE_POINTS)
|
@pytest.mark.parametrize("kite_points", KITE_POINTS)
|
||||||
def test_polygon_kite(
|
def test_polygon_kite(
|
||||||
|
|
|
@ -65,15 +65,32 @@ paste_mask_1(
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
if (imOut->image8) {
|
if (imOut->image8) {
|
||||||
|
int in_i16 = strncmp(imIn->mode, "I;16", 4) == 0;
|
||||||
|
int out_i16 = strncmp(imOut->mode, "I;16", 4) == 0;
|
||||||
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 (out_i16) {
|
||||||
|
out += dx;
|
||||||
|
}
|
||||||
UINT8 *in = imIn->image8[y + sy] + sx;
|
UINT8 *in = imIn->image8[y + sy] + sx;
|
||||||
|
if (in_i16) {
|
||||||
|
in += sx;
|
||||||
|
}
|
||||||
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++) {
|
||||||
if (*mask++) {
|
if (*mask) {
|
||||||
*out = *in;
|
*out = *in;
|
||||||
}
|
}
|
||||||
out++, in++;
|
if (in_i16) {
|
||||||
|
in++;
|
||||||
|
}
|
||||||
|
if (out_i16) {
|
||||||
|
out++;
|
||||||
|
if (*mask) {
|
||||||
|
*out = *in;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out++, in++, mask++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,15 +432,16 @@ fill_mask_L(
|
||||||
unsigned int tmp1;
|
unsigned int tmp1;
|
||||||
|
|
||||||
if (imOut->image8) {
|
if (imOut->image8) {
|
||||||
|
int i16 = strncmp(imOut->mode, "I;16", 4) == 0;
|
||||||
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) {
|
if (i16) {
|
||||||
out += dx;
|
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) {
|
if (i16) {
|
||||||
out++;
|
out++;
|
||||||
*out = BLEND(*mask, *out, ink[1], tmp1);
|
*out = BLEND(*mask, *out, ink[1], tmp1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user