Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/libImaging/Access.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static void
get_pixel_16L(Imaging im, int x, int y, void *color) {
UINT8 *in = (UINT8 *)&im->image[y][x + x];
#ifdef WORDS_BIGENDIAN
UINT16 out = in[0] + (in[1] << 8);
UINT16 out = in[0] + ((UINT16)in[1] << 8);
memcpy(color, &out, sizeof(out));
#else
memcpy(color, in, sizeof(UINT16));
Expand All @@ -77,7 +77,7 @@ get_pixel_16B(Imaging im, int x, int y, void *color) {
#ifdef WORDS_BIGENDIAN
memcpy(color, in, sizeof(UINT16));
#else
UINT16 out = in[1] + (in[0] << 8);
UINT16 out = in[1] + ((UINT16)in[0] << 8);
memcpy(color, &out, sizeof(out));
#endif
}
Expand All @@ -91,7 +91,8 @@ static void
get_pixel_32L(Imaging im, int x, int y, void *color) {
UINT8 *in = (UINT8 *)&im->image[y][x * 4];
#ifdef WORDS_BIGENDIAN
INT32 out = in[0] + (in[1] << 8) + (in[2] << 16) + (in[3] << 24);
INT32 out =
in[0] + ((INT32)in[1] << 8) + ((INT32)in[2] << 16) + ((INT32)in[3] << 24);
memcpy(color, &out, sizeof(out));
#else
memcpy(color, in, sizeof(INT32));
Expand All @@ -104,7 +105,8 @@ get_pixel_32B(Imaging im, int x, int y, void *color) {
#ifdef WORDS_BIGENDIAN
memcpy(color, in, sizeof(INT32));
#else
INT32 out = in[3] + (in[2] << 8) + (in[1] << 16) + (in[0] << 24);
INT32 out =
in[3] + ((INT32)in[2] << 8) + ((INT32)in[1] << 16) + ((INT32)in[0] << 24);
memcpy(color, &out, sizeof(out));
#endif
}
Expand Down
10 changes: 5 additions & 5 deletions src/libImaging/BcnEncode.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ decode_565(UINT16 x) {

static UINT16
encode_565(rgba item) {
UINT8 r, g, b;
r = item.color[0] >> (8 - 5);
g = item.color[1] >> (8 - 6);
b = item.color[2] >> (8 - 5);
UINT16 r = item.color[0] >> (8 - 5);
UINT8 g = item.color[1] >> (8 - 6);
UINT8 b = item.color[2] >> (8 - 5);
return (r << (5 + 6)) | (g << 5) | b;
}

Expand Down Expand Up @@ -157,7 +156,8 @@ encode_bc1_color(Imaging im, ImagingCodecState state, UINT8 *dst, int separate_a
static void
encode_bc2_block(Imaging im, ImagingCodecState state, UINT8 *dst) {
int i, j;
UINT8 block[16], current_alpha;
UINT8 block[16];
UINT32 current_alpha;
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
int x = state->x + i * im->pixelsize;
Expand Down
6 changes: 4 additions & 2 deletions src/libImaging/FliDecode.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@

#include "Imaging.h"

#define I16(ptr) ((ptr)[0] + ((ptr)[1] << 8))
#define I16(ptr) ((ptr)[0] + ((int)(ptr)[1] << 8))

#define I32(ptr) ((ptr)[0] + ((ptr)[1] << 8) + ((ptr)[2] << 16) + ((ptr)[3] << 24))
#define I32(ptr) \
((ptr)[0] + ((INT32)(ptr)[1] << 8) + ((INT32)(ptr)[2] << 16) + \
((INT32)(ptr)[3] << 24))

#define ERR_IF_DATA_OOB(offset) \
if ((data + (offset)) > ptr + bytes) { \
Expand Down
4 changes: 2 additions & 2 deletions src/libImaging/GetBBox.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ ImagingGetExtrema(Imaging im, void *extrema) {
UINT16 v;
UINT8 *pixel = *im->image8;
#ifdef WORDS_BIGENDIAN
v = pixel[0] + (pixel[1] << 8);
v = pixel[0] + ((UINT16)pixel[1] << 8);
#else
memcpy(&v, pixel, sizeof(v));
#endif
Expand All @@ -221,7 +221,7 @@ ImagingGetExtrema(Imaging im, void *extrema) {
for (x = 0; x < im->xsize; x++) {
pixel = (UINT8 *)im->image[y] + x * sizeof(v);
#ifdef WORDS_BIGENDIAN
v = pixel[0] + (pixel[1] << 8);
v = pixel[0] + ((UINT16)pixel[1] << 8);
#else
memcpy(&v, pixel, sizeof(v));
#endif
Expand Down
3 changes: 2 additions & 1 deletion src/libImaging/SgiRleDecode.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@

static void
read4B(UINT32 *dest, UINT8 *buf) {
*dest = (UINT32)((buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]);
*dest = ((UINT32)buf[0] << 24) | ((UINT32)buf[1] << 16) | ((UINT32)buf[2] << 8) |
buf[3];
}

/*
Expand Down
Loading