Skip to content

Commit

Permalink
Fixed linear_gradient I mode
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Feb 18, 2021
1 parent 1857bf5 commit 553ce81
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Tests/test_image.py
Expand Up @@ -521,7 +521,7 @@ def test_linear_gradient(self):

# Arrange
target_file = "Tests/images/linear_gradient.png"
for mode in ["L", "P"]:
for mode in ["L", "P", "I"]:

# Act
im = Image.linear_gradient(mode)
Expand Down
13 changes: 11 additions & 2 deletions src/libImaging/Fill.c
Expand Up @@ -76,8 +76,17 @@ ImagingFillLinearGradient(const char *mode) {
return NULL;
}

for (y = 0; y < 256; y++) {
memset(im->image8[y], (unsigned char)y, 256);
if (im->image8) {
for (y = 0; y < 256; y++) {
memset(im->image8[y], (unsigned char)y, 256);
}
} else {
int x;
for (y = 0; y < 256; y++) {
for (x = 0; x < 256; x++) {
im->image32[y][x] = y;
}
}
}

return im;
Expand Down

0 comments on commit 553ce81

Please sign in to comment.