1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-18 10:38:31 +02:00

Use SDL_BlitScaled in ScaleSurface

Why do all this error-prone per-pixel work when you can just use an SDL
function instead?
This commit is contained in:
Misa 2021-09-05 20:06:28 -07:00
parent 77696c0d55
commit fc2de88b03

View File

@ -166,16 +166,7 @@ SDL_Surface * ScaleSurface( SDL_Surface *_surface, int Width, int Height, SDL_Su
_ret = Dest;
}
float _stretch_factor_x = (static_cast<double>(Width) / static_cast<double>(_surface->w)), _stretch_factor_y = (static_cast<double>(Height) / static_cast<double>(_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<Sint32>(float(x)*_stretch_factor_x), static_cast<Sint32>(float(y) *_stretch_factor_y), static_cast<Sint32>(_stretch_factor_x),static_cast<Sint32>( _stretch_factor_y)) ;
SDL_FillRect(_ret, &gigantoPixel, ReadPixel(_surface, x, y));
}
SDL_BlitScaled(_surface, NULL, _ret, NULL);
return _ret;
}