From fc2de88b03a82875074609a63d693ca10af6c210 Mon Sep 17 00:00:00 2001 From: Misa Date: Sun, 5 Sep 2021 20:06:28 -0700 Subject: [PATCH] Use `SDL_BlitScaled` in `ScaleSurface` Why do all this error-prone per-pixel work when you can just use an SDL function instead? --- desktop_version/src/GraphicsUtil.cpp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/desktop_version/src/GraphicsUtil.cpp b/desktop_version/src/GraphicsUtil.cpp index 3bdaadfd..0468d50c 100644 --- a/desktop_version/src/GraphicsUtil.cpp +++ b/desktop_version/src/GraphicsUtil.cpp @@ -166,16 +166,7 @@ SDL_Surface * ScaleSurface( SDL_Surface *_surface, int Width, int Height, SDL_Su _ret = Dest; } - float _stretch_factor_x = (static_cast(Width) / static_cast(_surface->w)), _stretch_factor_y = (static_cast(Height) / static_cast(_surface->h)); - - - SDL_Rect gigantoPixel; - for(Sint32 y = 0; y < _surface->h; y++) - for(Sint32 x = 0; x < _surface->w; x++) - { - setRect(gigantoPixel, static_cast(float(x)*_stretch_factor_x), static_cast(float(y) *_stretch_factor_y), static_cast(_stretch_factor_x),static_cast( _stretch_factor_y)) ; - SDL_FillRect(_ret, &gigantoPixel, ReadPixel(_surface, x, y)); - } + SDL_BlitScaled(_surface, NULL, _ret, NULL); return _ret; }