@@ -1265,11 +1265,12 @@ surf_get_colorkey(pgSurfaceObject *self, PyObject *_null)
12651265
12661266 SURF_INIT_CHECK (surf )
12671267
1268- if (SDL_GetColorKey (surf , & mapped_color ) != 0 ) {
1269- SDL_ClearError ();
1268+ if (!SDL_HasColorKey (surf )) {
12701269 Py_RETURN_NONE ;
12711270 }
12721271
1272+ SDL_GetColorKey (surf , & mapped_color );
1273+
12731274 if (SDL_ISPIXELFORMAT_ALPHA (surf -> format -> format ))
12741275 SDL_GetRGBA (mapped_color , surf -> format , & r , & g , & b , & a );
12751276 else
@@ -1430,8 +1431,8 @@ surf_convert(pgSurfaceObject *self, PyObject *args)
14301431
14311432 pgSurface_Prep (self );
14321433
1433- if (SDL_GetColorKey ( surf , & colorkey ) == 0 ) {
1434- has_colorkey = SDL_TRUE ;
1434+ if (( has_colorkey = SDL_HasColorKey ( surf )) ) {
1435+ SDL_GetColorKey ( surf , & colorkey ) ;
14351436 if (SDL_ISPIXELFORMAT_ALPHA (surf -> format -> format ))
14361437 SDL_GetRGBA (colorkey , surf -> format , & key_r , & key_g , & key_b ,
14371438 & key_a );
@@ -2434,7 +2435,7 @@ surf_get_flags(PyObject *self, PyObject *_null)
24342435 if (is_alpha ) {
24352436 flags |= PGS_SRCALPHA ;
24362437 }
2437- if (SDL_GetColorKey (surf , NULL ) == 0 )
2438+ if (SDL_HasColorKey (surf ) )
24382439 flags |= PGS_SRCCOLORKEY ;
24392440 if (sdl_flags & SDL_PREALLOC )
24402441 flags |= PGS_PREALLOC ;
@@ -2615,7 +2616,6 @@ surf_subsurface(PyObject *self, PyObject *args)
26152616 struct pgSubSurface_Data * data ;
26162617 Uint8 alpha ;
26172618 Uint32 colorkey ;
2618- int ecode ;
26192619
26202620 SURF_INIT_CHECK (surf )
26212621
@@ -2679,21 +2679,14 @@ surf_subsurface(PyObject *self, PyObject *args)
26792679 return NULL ;
26802680 }
26812681 }
2682- ecode = SDL_GetColorKey ( surf , & colorkey );
2683- if ( ecode == 0 ) {
2682+ if ( SDL_HasColorKey ( surf )) {
2683+ SDL_GetColorKey ( surf , & colorkey );
26842684 if (SDL_SetColorKey (sub , SDL_TRUE , colorkey ) != 0 ) {
26852685 PyErr_SetString (pgExc_SDLError , SDL_GetError ());
26862686 SDL_FreeSurface (sub );
26872687 return NULL ;
26882688 }
26892689 }
2690- else if (ecode == -1 )
2691- SDL_ClearError ();
2692- else {
2693- PyErr_SetString (pgExc_SDLError , SDL_GetError ());
2694- SDL_FreeSurface (sub );
2695- return NULL ;
2696- }
26972690
26982691 data = PyMem_New (struct pgSubSurface_Data , 1 );
26992692 if (!data )
@@ -2839,8 +2832,8 @@ surf_get_bounding_rect(PyObject *self, PyObject *args, PyObject *kwargs)
28392832
28402833 format = surf -> format ;
28412834
2842- if (SDL_GetColorKey ( surf , & colorkey ) == 0 ) {
2843- has_colorkey = 1 ;
2835+ if (( has_colorkey = SDL_HasColorKey ( surf )) ) {
2836+ SDL_GetColorKey ( surf , & colorkey ) ;
28442837 SDL_GetRGBA (colorkey , surf -> format , & keyr , & keyg , & keyb , & a );
28452838 }
28462839
0 commit comments