@@ -1690,7 +1690,7 @@ SaveTGA_RW(SDL_Surface *surface, SDL_RWops *out, int rle)
1690
1690
int alpha = 0 ;
1691
1691
struct TGAheader h ;
1692
1692
int srcbpp ;
1693
- Uint8 surf_alpha ;
1693
+ SDL_BlendMode surf_blendmode ;
1694
1694
int have_surf_colorkey = 0 ;
1695
1695
Uint32 surf_colorkey ;
1696
1696
SDL_Rect r ;
@@ -1721,7 +1721,15 @@ SaveTGA_RW(SDL_Surface *surface, SDL_RWops *out, int rle)
1721
1721
SDL_PixelFormatEnum output_format ;
1722
1722
#endif
1723
1723
1724
- SDL_GetSurfaceAlphaMod (surface , & surf_alpha );
1724
+ #if SDL_VERSION_ATLEAST (3 , 0 , 0 )
1725
+ if (!SDL_GetSurfaceBlendMode (surface , & surf_blendmode ))
1726
+ #else
1727
+ if (SDL_GetSurfaceBlendMode (surface , & surf_blendmode ) < 0 )
1728
+ #endif
1729
+ {
1730
+ PyErr_SetString (pgExc_SDLError , SDL_GetError ());
1731
+ return -1 ;
1732
+ }
1725
1733
if ((have_surf_colorkey = SDL_HasColorKey (surface ))) {
1726
1734
SDL_GetColorKey (surface , & surf_colorkey );
1727
1735
}
@@ -1811,12 +1819,8 @@ SaveTGA_RW(SDL_Surface *surface, SDL_RWops *out, int rle)
1811
1819
}
1812
1820
}
1813
1821
1814
- /* Temporarily remove colorkey and alpha from surface so copies are
1815
- opaque */
1816
- SDL_SetSurfaceAlphaMod (surface , SDL_ALPHA_OPAQUE );
1817
- if (have_surf_colorkey ) {
1818
- SDL_SetColorKey (surface , SDL_FALSE , surf_colorkey );
1819
- }
1822
+ /* Temporarily set SDL_BLENDMODE_NONE so that copies are opaque */
1823
+ SDL_SetSurfaceBlendMode (surface , SDL_BLENDMODE_NONE );
1820
1824
1821
1825
r .x = 0 ;
1822
1826
r .w = surface -> w ;
@@ -1847,10 +1851,7 @@ SaveTGA_RW(SDL_Surface *surface, SDL_RWops *out, int rle)
1847
1851
}
1848
1852
1849
1853
/* restore flags */
1850
- SDL_SetSurfaceAlphaMod (surface , surf_alpha );
1851
- if (have_surf_colorkey ) {
1852
- SDL_SetColorKey (surface , SDL_TRUE , surf_colorkey );
1853
- }
1854
+ SDL_SetSurfaceBlendMode (surface , surf_blendmode );
1854
1855
1855
1856
free (rlebuf );
1856
1857
SDL_FreeSurface (linebuf );
0 commit comments