diff --git a/src/formats/jpeg.c b/src/formats/jpeg.c index 9f60de7..b0aadfd 100644 --- a/src/formats/jpeg.c +++ b/src/formats/jpeg.c @@ -76,7 +76,8 @@ enum loader_status decode_jpeg(struct image* ctx, const uint8_t* data, uint32_t* pixel = (uint32_t*)line; for (int x = jpg.output_width - 1; x >= 0; --x) { const uint8_t src = *(line + x); - pixel[x] = (0xff << 24) | src << 16 | src << 8 | src; + pixel[x] = ((argb_t)0xff << 24) | (argb_t)src << 16 | + (argb_t)src << 8 | src; } } @@ -86,7 +87,8 @@ enum loader_status decode_jpeg(struct image* ctx, const uint8_t* data, uint32_t* pixel = (uint32_t*)line; for (int x = jpg.output_width - 1; x >= 0; --x) { const uint8_t* src = line + x * 3; - pixel[x] = (0xff << 24) | src[0] << 16 | src[1] << 8 | src[2]; + pixel[x] = ((argb_t)0xff << 24) | (argb_t)src[0] << 16 | + (argb_t)src[1] << 8 | src[2]; } } #endif // LIBJPEG_TURBO_VERSION diff --git a/src/pixmap.h b/src/pixmap.h index c063756..c21162e 100644 --- a/src/pixmap.h +++ b/src/pixmap.h @@ -25,10 +25,10 @@ typedef uint32_t argb_t; #define ARGB_GET_B(c) (((c) >> ARGB_B_SHIFT) & 0xff) // create argb_t from channel value -#define ARGB_SET_A(a) (((a) & 0xff) << ARGB_A_SHIFT) -#define ARGB_SET_R(r) (((r) & 0xff) << ARGB_R_SHIFT) -#define ARGB_SET_G(g) (((g) & 0xff) << ARGB_G_SHIFT) -#define ARGB_SET_B(b) (((b) & 0xff) << ARGB_B_SHIFT) +#define ARGB_SET_A(a) (((argb_t)(a) & 0xff) << ARGB_A_SHIFT) +#define ARGB_SET_R(r) (((argb_t)(r) & 0xff) << ARGB_R_SHIFT) +#define ARGB_SET_G(g) (((argb_t)(g) & 0xff) << ARGB_G_SHIFT) +#define ARGB_SET_B(b) (((argb_t)(b) & 0xff) << ARGB_B_SHIFT) // convert ABGR to ARGB #define ABGR_TO_ARGB(c) \