Skip to content

Commit 36fc1c2

Browse files
committed
Fixed texture colorspace when creating a texture from a surface
Fixes #12691
1 parent 5124858 commit 36fc1c2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/render/SDL_render.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,8 +1677,6 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s
16771677
}
16781678
}
16791679

1680-
surface_colorspace = SDL_GetSurfaceColorspace(surface);
1681-
16821680
// Try to have the best pixel format for the texture
16831681
// No alpha, but a colorkey => promote to alpha
16841682
if (!SDL_ISPIXELFORMAT_ALPHA(surface->format) && SDL_SurfaceHasColorKey(surface)) {
@@ -1740,6 +1738,9 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s
17401738
}
17411739
}
17421740

1741+
surface_colorspace = SDL_GetSurfaceColorspace(surface);
1742+
texture_colorspace = surface_colorspace;
1743+
17431744
if (surface_colorspace == SDL_COLORSPACE_SRGB_LINEAR ||
17441745
SDL_COLORSPACETRANSFER(surface_colorspace) == SDL_TRANSFER_CHARACTERISTICS_PQ) {
17451746
if (SDL_ISPIXELFORMAT_FLOAT(format)) {

0 commit comments

Comments
 (0)