Fixed compiler warning

This commit is contained in:
Sam Lantinga 2021-10-30 21:42:07 -07:00
parent cd66c050fe
commit a01aaf053c
1 changed files with 6 additions and 7 deletions

View File

@ -1238,19 +1238,18 @@ SDL_PremultiplySurfaceAlphaToARGB8888(SDL_Surface *src, Uint32 *dst)
SDL_LockSurface(src); SDL_LockSurface(src);
for (y = 0; y < src->h; ++y) { for (y = 0; y < src->h; ++y) {
Uint8 *src_px = (Uint8*)(src->pixels) + (y * src->pitch); Uint32 *src_px = (Uint32*)((Uint8 *)src->pixels + (y * src->pitch));
for (x = 0; x < src->w; ++x) { for (x = 0; x < src->w; ++x) {
/* Component bytes extraction. */ /* Component bytes extraction. */
SDL_GetRGBA(*(Uint32*)src_px, src->format, &R, &G, &B, &A); SDL_GetRGBA(*src_px++, src->format, &R, &G, &B, &A);
src_px += src->format->BytesPerPixel;
/* Alpha pre-multiplication of each component. */ /* Alpha pre-multiplication of each component. */
R = (float)A * ((float)R /255); R = ((Uint32)A * R) / 255;
G = (float)A * ((float)G /255); G = ((Uint32)A * G) / 255;
B = (float)A * ((float)B /255); B = ((Uint32)A * B) / 255;
/* ARGB8888 pixel recomposition. */ /* ARGB8888 pixel recomposition. */
(*dst++) = (((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8)) | ((Uint32)B << 0); *dst++ = (((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | (B << 0));
} }
} }
if (SDL_MUSTLOCK(src)) if (SDL_MUSTLOCK(src))