Skip to content

Commit 908d3ef

Browse files
authored
Fix handling all color types in pygame.transform.threshold (#3156)
* Handle more color values in _color_from_obj * Test all color arguments
1 parent 23bbb3b commit 908d3ef

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src_c/transform.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1830,7 +1830,7 @@ _color_from_obj(PyObject *color_obj, SDL_Surface *surf, Uint8 rgba_default[4],
18301830
{
18311831
if (color_obj) {
18321832
if (!pg_MappedColorFromObj(color_obj, surf, color,
1833-
PG_COLOR_HANDLE_INT)) {
1833+
PG_COLOR_HANDLE_ALL)) {
18341834
return -1;
18351835
}
18361836
}

test/transform_test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,13 @@ def test_threshold__subclassed_surface(self):
11471147
self.assertEqual(dest_surface.get_size(), expected_size)
11481148
self.assertEqual(dest_surface.get_flags(), expected_flags)
11491149

1150+
def test_threshold_all_color_types(self):
1151+
s1 = pygame.Surface((32, 32), SRCALPHA, 32)
1152+
s2 = pygame.Surface((32, 32), SRCALPHA, 32)
1153+
1154+
for color in [(0, 255, 0), (255, 0, 0, 0), 0, "blue", pygame.Color("#FFFFFF")]:
1155+
pygame.transform.threshold(s1, s2, color, color, color)
1156+
11501157
def test_laplacian(self):
11511158
""" """
11521159

0 commit comments

Comments
 (0)