Avoid some more undefined behaviors with shifts

This commit is contained in:
Kim Woelders 2023-01-13 10:54:16 +01:00
parent e76d9bcf9f
commit 207cffb207
3 changed files with 6 additions and 5 deletions

View File

@ -58,7 +58,7 @@ typedef struct _ImlibImage ImlibImage;
#define SWAP_LE_32_INPLACE(x)
#endif
#define PIXEL_ARGB(a, r, g, b) ((a) << 24) | ((r) << 16) | ((g) << 8) | (b)
#define PIXEL_ARGB(a, r, g, b) ((uint32_t)(a) << 24) | ((r) << 16) | ((g) << 8) | (b)
#define PIXEL_A(argb) (((argb) >> 24) & 0xff)
#define PIXEL_R(argb) (((argb) >> 16) & 0xff)

View File

@ -36,7 +36,7 @@
#define SWAP_LE_32_INPLACE(x)
#endif
#define PIXEL_ARGB(a, r, g, b) ((a) << 24) | ((r) << 16) | ((g) << 8) | (b)
#define PIXEL_ARGB(a, r, g, b) ((uint32_t)(a) << 24) | ((r) << 16) | ((g) << 8) | (b)
#define PIXEL_A(argb) (((argb) >> 24) & 0xff)
#define PIXEL_R(argb) (((argb) >> 16) & 0xff)

View File

@ -414,11 +414,12 @@ _load(ImlibImage * im, int load_data)
{
psrc = &pxls[(y * w + x) * ie->bih.bpp / 8];
pixel = PIXEL_ARGB(0, psrc[2], psrc[1], psrc[0]);
i = 0;
if (ie->bih.bpp == 32)
pixel |= psrc[3] << 24;
i = psrc[3];
else if (ico_data_get_bit(mask, w, x, y) == 0)
pixel |= 0xff000000;
i = 0xff;
pixel = PIXEL_ARGB(i, psrc[2], psrc[1], psrc[0]);
*pdst++ = pixel;
}