Use the surface palette when creating a texture from a surface

Fixes https://github.com/libsdl-org/SDL/issues/16227
This commit is contained in:
Sam Lantinga
2026-09-01 16:38:16 -07:00
parent 757400e044
commit c8d08ea2df

View File

@@ -1885,6 +1885,7 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s
SDL_SetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER, SDL_TEXTUREACCESS_STATIC);
SDL_SetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER, surface->w);
SDL_SetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER, surface->h);
SDL_SetPointerProperty(props, SDL_PROP_TEXTURE_CREATE_PALETTE_POINTER, surface->palette);
texture = SDL_CreateTextureWithProperties(renderer, props);
SDL_DestroyProperties(props);