Fixed scaling YUV surfaces

This commit is contained in:
Sam Lantinga
2025-11-08 10:01:27 -08:00
parent 7553d5892e
commit 7d628ef76c

View File

@@ -2227,7 +2227,7 @@ SDL_Surface *SDL_ScaleSurface(SDL_Surface *surface, int width, int height, SDL_S
if (SDL_ISPIXELFORMAT_FOURCC(surface->format)) {
// We can't directly scale a YUV surface (yet!)
SDL_Surface *tmp = SDL_CreateSurface(surface->w, surface->h, SDL_PIXELFORMAT_ARGB8888);
SDL_Surface *tmp = SDL_ConvertSurface(surface, SDL_PIXELFORMAT_ARGB8888);
if (!tmp) {
return NULL;
}
@@ -2237,10 +2237,9 @@ SDL_Surface *SDL_ScaleSurface(SDL_Surface *surface, int width, int height, SDL_S
if (!scaled) {
return NULL;
}
tmp = scaled;
SDL_Surface *result = SDL_ConvertSurfaceAndColorspace(tmp, surface->format, NULL, surface->colorspace, surface->props);
SDL_DestroySurface(tmp);
SDL_Surface *result = SDL_ConvertSurfaceAndColorspace(scaled, surface->format, NULL, surface->colorspace, surface->props);
SDL_DestroySurface(scaled);
return result;
}