mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-17 18:28:28 +00:00
Clamp the texture alpha and color modulation values to 0-255
This commit is contained in:
parent
541ba33714
commit
dcbb2f11a8
1 changed files with 4 additions and 4 deletions
|
@ -1812,13 +1812,13 @@ bool SDL_GetTextureColorMod(SDL_Texture *texture, Uint8 *r, Uint8 *g, Uint8 *b)
|
|||
}
|
||||
|
||||
if (r) {
|
||||
*r = (Uint8)(fR * 255.0f);
|
||||
*r = (Uint8)SDL_roundf(SDL_clamp(fR, 0.0f, 1.0f) * 255.0f);
|
||||
}
|
||||
if (g) {
|
||||
*g = (Uint8)(fG * 255.0f);
|
||||
*g = (Uint8)SDL_roundf(SDL_clamp(fG, 0.0f, 1.0f) * 255.0f);
|
||||
}
|
||||
if (b) {
|
||||
*b = (Uint8)(fB * 255.0f);
|
||||
*b = (Uint8)SDL_roundf(SDL_clamp(fB, 0.0f, 1.0f) * 255.0f);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1883,7 +1883,7 @@ bool SDL_GetTextureAlphaMod(SDL_Texture *texture, Uint8 *alpha)
|
|||
}
|
||||
|
||||
if (alpha) {
|
||||
*alpha = (Uint8)(fA * 255.0f);
|
||||
*alpha = (Uint8)SDL_roundf(SDL_clamp(fA, 0.0f, 1.0f) * 255.0f);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue