Palettized textures will always use SDL_SCALEMODE_NEAREST.

Our algorithm for pixel art doesn't work on 8-bit images, needs further investigation.

Fixes https://github.com/libsdl-org/SDL/issues/14129
This commit is contained in:
Sam Lantinga
2025-10-03 14:29:47 -07:00
parent d333044462
commit 32668c4ddd
2 changed files with 5 additions and 7 deletions

View File

@@ -1234,8 +1234,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureBlendMode(SDL_Texture *texture, S
* The default texture scale mode is SDL_SCALEMODE_LINEAR. * The default texture scale mode is SDL_SCALEMODE_LINEAR.
* *
* If the scale mode is not supported, the closest supported mode is chosen. * If the scale mode is not supported, the closest supported mode is chosen.
* Palettized textures will use SDL_SCALEMODE_PIXELART instead of * Palettized textures will always use SDL_SCALEMODE_NEAREST.
* SDL_SCALEMODE_LINEAR.
* *
* \param texture the texture to update. * \param texture the texture to update.
* \param scaleMode the SDL_ScaleMode to use for texture scaling. * \param scaleMode the SDL_ScaleMode to use for texture scaling.

View File

@@ -1525,9 +1525,8 @@ SDL_Texture *SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_Propert
texture->color.b = 1.0f; texture->color.b = 1.0f;
texture->color.a = 1.0f; texture->color.a = 1.0f;
texture->blendMode = SDL_ISPIXELFORMAT_ALPHA(format) ? SDL_BLENDMODE_BLEND : SDL_BLENDMODE_NONE; texture->blendMode = SDL_ISPIXELFORMAT_ALPHA(format) ? SDL_BLENDMODE_BLEND : SDL_BLENDMODE_NONE;
if (renderer->scale_mode == SDL_SCALEMODE_LINEAR && if (SDL_ISPIXELFORMAT_INDEXED(format)) {
SDL_ISPIXELFORMAT_INDEXED(format)) { texture->scaleMode = SDL_SCALEMODE_NEAREST;
texture->scaleMode = SDL_SCALEMODE_PIXELART;
} else { } else {
texture->scaleMode = renderer->scale_mode; texture->scaleMode = renderer->scale_mode;
} }
@@ -2163,11 +2162,11 @@ bool SDL_SetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode scaleMode)
switch (scaleMode) { switch (scaleMode) {
case SDL_SCALEMODE_NEAREST: case SDL_SCALEMODE_NEAREST:
case SDL_SCALEMODE_PIXELART:
break; break;
case SDL_SCALEMODE_PIXELART:
case SDL_SCALEMODE_LINEAR: case SDL_SCALEMODE_LINEAR:
if (SDL_ISPIXELFORMAT_INDEXED(texture->format)) { if (SDL_ISPIXELFORMAT_INDEXED(texture->format)) {
scaleMode = SDL_SCALEMODE_PIXELART; scaleMode = SDL_SCALEMODE_NEAREST;
} }
break; break;
default: default: