Skip to content

Commit 553ce81

Browse files
committed
Fixed linear_gradient I mode
1 parent 1857bf5 commit 553ce81

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Tests/test_image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ def test_linear_gradient(self):
521521

522522
# Arrange
523523
target_file = "Tests/images/linear_gradient.png"
524-
for mode in ["L", "P"]:
524+
for mode in ["L", "P", "I"]:
525525

526526
# Act
527527
im = Image.linear_gradient(mode)

src/libImaging/Fill.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,17 @@ ImagingFillLinearGradient(const char *mode) {
7676
return NULL;
7777
}
7878

79-
for (y = 0; y < 256; y++) {
80-
memset(im->image8[y], (unsigned char)y, 256);
79+
if (im->image8) {
80+
for (y = 0; y < 256; y++) {
81+
memset(im->image8[y], (unsigned char)y, 256);
82+
}
83+
} else {
84+
int x;
85+
for (y = 0; y < 256; y++) {
86+
for (x = 0; x < 256; x++) {
87+
im->image32[y][x] = y;
88+
}
89+
}
8190
}
8291

8392
return im;

0 commit comments

Comments
 (0)