Skip to content

Commit

Permalink
Using uint* for pixel access in mode I;16 and I;32, fixes #452
Browse files Browse the repository at this point in the history
  • Loading branch information
wiredfool committed Dec 20, 2013
1 parent 598d97d commit 77c36d6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions _imaging.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,14 +463,14 @@ getpixel(Imaging im, ImagingAccess access, int x, int y)
{
union {
UINT8 b[4];
INT16 h;
INT32 i;
UINT16 h;
UINT32 i;
FLOAT32 f;
} pixel;

if (x < 0 || x >= im->xsize || y < 0 || y >= im->ysize) {
PyErr_SetString(PyExc_IndexError, outside_image);
return NULL;
PyErr_SetString(PyExc_IndexError, outside_image);
return NULL;
}

access->get_pixel(im, x, y, &pixel);
Expand Down
16 changes: 8 additions & 8 deletions libImaging/Access.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,21 @@ static void
get_pixel_16L(Imaging im, int x, int y, void* color)
{
UINT8* in = (UINT8*) &im->image[y][x+x];
INT16* out = color;
UINT16* out = color;
#ifdef WORDS_BIGENDIAN
out[0] = in[0] + (in[1]<<8);
#else
out[0] = *(INT16*) in;
out[0] = *(UINT16*) in;
#endif
}

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

static void
get_pixel_32B(Imaging im, int x, int y, void* color)
{
UINT8* in = (UINT8*) &im->image[y][x*4];
INT32* out = color;
UINT32* out = color;
#ifdef WORDS_BIGENDIAN
out[0] = *(INT32*) in;
out[0] = *(UINT32*) in;
#else
out[0] = in[3] + (in[2]<<8) + (in[1]<<16) + (in[0]<<24);
#endif
Expand Down

0 comments on commit 77c36d6

Please sign in to comment.