Using uint* for pixel access in mode I;16 and I;32, fixes #452

This commit is contained in:
wiredfool 2013-12-19 21:39:18 -08:00
parent 598d97daff
commit 77c36d6edc
2 changed files with 12 additions and 12 deletions

View File

@ -463,8 +463,8 @@ getpixel(Imaging im, ImagingAccess access, int x, int y)
{ {
union { union {
UINT8 b[4]; UINT8 b[4];
INT16 h; UINT16 h;
INT32 i; UINT32 i;
FLOAT32 f; FLOAT32 f;
} pixel; } pixel;

View File

@ -94,11 +94,11 @@ static void
get_pixel_16L(Imaging im, int x, int y, void* color) get_pixel_16L(Imaging im, int x, int y, void* color)
{ {
UINT8* in = (UINT8*) &im->image[y][x+x]; UINT8* in = (UINT8*) &im->image[y][x+x];
INT16* out = color; UINT16* out = color;
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
out[0] = in[0] + (in[1]<<8); out[0] = in[0] + (in[1]<<8);
#else #else
out[0] = *(INT16*) in; out[0] = *(UINT16*) in;
#endif #endif
} }
@ -106,9 +106,9 @@ static void
get_pixel_16B(Imaging im, int x, int y, void* color) get_pixel_16B(Imaging im, int x, int y, void* color)
{ {
UINT8* in = (UINT8*) &im->image[y][x+x]; UINT8* in = (UINT8*) &im->image[y][x+x];
INT16* out = color; UINT16* out = color;
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
out[0] = *(INT16*) in; out[0] = *(UINT16*) in;
#else #else
out[0] = in[1] + (in[0]<<8); out[0] = in[1] + (in[0]<<8);
#endif #endif
@ -125,11 +125,11 @@ static void
get_pixel_32L(Imaging im, int x, int y, void* color) get_pixel_32L(Imaging im, int x, int y, void* color)
{ {
UINT8* in = (UINT8*) &im->image[y][x*4]; UINT8* in = (UINT8*) &im->image[y][x*4];
INT32* out = color; UINT32* out = color;
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
out[0] = in[0] + (in[1]<<8) + (in[2]<<16) + (in[3]<<24); out[0] = in[0] + (in[1]<<8) + (in[2]<<16) + (in[3]<<24);
#else #else
out[0] = *(INT32*) in; out[0] = *(UINT32*) in;
#endif #endif
} }
@ -137,9 +137,9 @@ static void
get_pixel_32B(Imaging im, int x, int y, void* color) get_pixel_32B(Imaging im, int x, int y, void* color)
{ {
UINT8* in = (UINT8*) &im->image[y][x*4]; UINT8* in = (UINT8*) &im->image[y][x*4];
INT32* out = color; UINT32* out = color;
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
out[0] = *(INT32*) in; out[0] = *(UINT32*) in;
#else #else
out[0] = in[3] + (in[2]<<8) + (in[1]<<16) + (in[0]<<24); out[0] = in[3] + (in[2]<<8) + (in[1]<<16) + (in[0]<<24);
#endif #endif