Skip to content

Commit 7d3eda0

Browse files
committed
Add _get_color_from_object_all
1 parent 23bbb3b commit 7d3eda0

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src_c/pixelarray_methods.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ _get_color_from_object(PyObject *val, SDL_Surface *surf, Uint32 *color)
4646
val, surf, color, PG_COLOR_HANDLE_INT | PG_COLOR_HANDLE_RESTRICT_SEQ);
4747
}
4848

49+
static int
50+
_get_color_from_object_all(PyObject *val, SDL_Surface *surf, Uint32 *color)
51+
{
52+
if (!val) {
53+
return 0;
54+
}
55+
56+
return pg_MappedColorFromObj(val, surf, color, PG_COLOR_HANDLE_ALL);
57+
}
58+
4959
/**
5060
* Retrieves a single pixel located at index from the surface pixel
5161
* array.
@@ -375,8 +385,8 @@ _replace_color(pgPixelArrayObject *array, PyObject *args, PyObject *kwds)
375385
format = surf->format;
376386
bpp = PG_SURF_BytesPerPixel(surf);
377387

378-
if (!_get_color_from_object(delcolor, surf, &dcolor) ||
379-
!_get_color_from_object(replcolor, surf, &rcolor)) {
388+
if (!_get_color_from_object_all(delcolor, surf, &dcolor) ||
389+
!_get_color_from_object_all(replcolor, surf, &rcolor)) {
380390
return 0;
381391
}
382392

@@ -581,7 +591,7 @@ _extract_color(pgPixelArrayObject *array, PyObject *args, PyObject *kwds)
581591
black = SDL_MapRGBA(format, 0, 0, 0, 255);
582592
white = SDL_MapRGBA(format, 255, 255, 255, 255);
583593

584-
if (!_get_color_from_object(excolor, surf, &color)) {
594+
if (!_get_color_from_object_all(excolor, surf, &color)) {
585595
Py_DECREF(new_array);
586596
return 0;
587597
}

0 commit comments

Comments
 (0)