@@ -263,39 +263,6 @@ pg_DisplayFormat(SDL_Surface *surface);
263263static int
264264_PgSurface_SrcAlpha (SDL_Surface * surf );
265265
266- #if !SDL_VERSION_ATLEAST (2 , 0 , 10 )
267- static Uint32
268- pg_map_rgb (SDL_Surface * surf , Uint8 r , Uint8 g , Uint8 b )
269- {
270- /* SDL_MapRGB() returns wrong values for color keys
271- for indexed formats since since alpha = 0 */
272- Uint32 key ;
273- if (!surf -> format -> palette )
274- return SDL_MapRGB (surf -> format , r , g , b );
275- if (!SDL_GetColorKey (surf , & key )) {
276- Uint8 keyr , keyg , keyb ;
277- SDL_GetRGB (key , surf -> format , & keyr , & keyg , & keyb );
278- if (r == keyr && g == keyg && b == keyb )
279- return key ;
280- }
281- else
282- SDL_ClearError ();
283- return SDL_MapRGBA (surf -> format , r , g , b , SDL_ALPHA_OPAQUE );
284- }
285-
286- static Uint32
287- pg_map_rgba (SDL_Surface * surf , Uint8 r , Uint8 g , Uint8 b , Uint8 a )
288- {
289- if (!surf -> format -> palette )
290- return SDL_MapRGBA (surf -> format , r , g , b , a );
291- return pg_map_rgb (surf , r , g , b );
292- }
293- #else /* SDL_VERSION_ATLEAST(2, 0, 10) */
294- #define pg_map_rgb (surf , r , g , b ) SDL_MapRGB((surf)->format, (r), (g), (b))
295- #define pg_map_rgba (surf , r , g , b , a ) \
296- SDL_MapRGBA((surf)->format, (r), (g), (b), (a))
297- #endif /* SDL_VERSION_ATLEAST(2, 0, 10) */
298-
299266static PyGetSetDef surface_getsets [] = {
300267 {"_pixels_address" , (getter )surf_get_pixels_address , NULL ,
301268 "pixel buffer address (readonly)" , NULL },
@@ -976,7 +943,7 @@ surf_map_rgb(PyObject *self, PyObject *args)
976943
977944 SURF_INIT_CHECK (surf )
978945
979- color = pg_map_rgba (surf , rgba [0 ], rgba [1 ], rgba [2 ], rgba [3 ]);
946+ color = SDL_MapRGBA (surf -> format , rgba [0 ], rgba [1 ], rgba [2 ], rgba [3 ]);
980947 return PyLong_FromLong (color );
981948}
982949
@@ -1604,7 +1571,7 @@ surf_convert(pgSurfaceObject *self, PyObject *args)
16041571 }
16051572
16061573 if (has_colorkey ) {
1607- colorkey = pg_map_rgba (newsurf , key_r , key_g , key_b , key_a );
1574+ colorkey = SDL_MapRGBA (newsurf -> format , key_r , key_g , key_b , key_a );
16081575 if (SDL_SetColorKey (newsurf , SDL_TRUE , colorkey ) != 0 ) {
16091576 PyErr_SetString (pgExc_SDLError , SDL_GetError ());
16101577 SDL_FreeSurface (newsurf );
0 commit comments