From 7d628ef76c0b039037bfc5d27475eb8aebec6963 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 8 Nov 2025 10:01:27 -0800 Subject: [PATCH] Fixed scaling YUV surfaces --- src/video/SDL_surface.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index 104b7b9d5d..5f1e96c035 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -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; }