@@ -1590,32 +1590,33 @@ surf_convert(pgSurfaceObject *self, PyObject *args)
15901590static SDL_Surface *
15911591pg_DisplayFormat (SDL_Surface * surface )
15921592{
1593- SDL_Surface * displaysurf ;
1594- if (!pg_GetDefaultWindowSurface ()) {
1595- SDL_SetError ("No video mode has been set" );
1593+ SDL_PixelFormat * default_format = pg_GetDefaultConvertFormat ();
1594+ if (!default_format ) {
1595+ SDL_SetError (
1596+ "No convert format has been set, try display.set_mode()"
1597+ " or Window.get_surface()." );
15961598 return NULL ;
15971599 }
1598- displaysurf = pgSurface_AsSurface (pg_GetDefaultWindowSurface ());
1599- return PG_ConvertSurface (surface , displaysurf -> format );
1600+ return PG_ConvertSurface (surface , default_format );
16001601}
16011602
16021603static SDL_Surface *
16031604pg_DisplayFormatAlpha (SDL_Surface * surface )
16041605{
1605- SDL_Surface * displaysurf ;
16061606 SDL_PixelFormat * dformat ;
16071607 Uint32 pfe ;
16081608 Uint32 amask = 0xff000000 ;
16091609 Uint32 rmask = 0x00ff0000 ;
16101610 Uint32 gmask = 0x0000ff00 ;
16111611 Uint32 bmask = 0x000000ff ;
16121612
1613- if (!pg_GetDefaultWindowSurface ()) {
1614- SDL_SetError ("No video mode has been set" );
1613+ dformat = pg_GetDefaultConvertFormat ();
1614+ if (!dformat ) {
1615+ SDL_SetError (
1616+ "No convert format has been set, try display.set_mode()"
1617+ " or Window.get_surface()." );
16151618 return NULL ;
16161619 }
1617- displaysurf = pgSurface_AsSurface (pg_GetDefaultWindowSurface ());
1618- dformat = displaysurf -> format ;
16191620
16201621 switch (dformat -> BytesPerPixel ) {
16211622 case 2 :
0 commit comments