Skip to content

Commit

Permalink
Merge pull request #7296 from radarhere/access
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk authored Jul 22, 2023
2 parents ea0abb9 + 577a4d8 commit 06e66f7
Showing 1 changed file with 7 additions and 27 deletions.
34 changes: 7 additions & 27 deletions src/libImaging/Access.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,11 @@ add_item(const char *mode) {
/* fetch individual pixel */

static void
get_pixel(Imaging im, int x, int y, void *color) {
get_pixel_32_2bands(Imaging im, int x, int y, void *color) {
char *out = color;

/* generic pixel access*/

if (im->image8) {
out[0] = im->image8[y][x];
} else {
UINT8 *p = (UINT8 *)&im->image32[y][x];
if (im->type == IMAGING_TYPE_UINT8 && im->bands == 2) {
out[0] = p[0];
out[1] = p[3];
return;
}
memcpy(out, p, im->pixelsize);
}
UINT8 *p = (UINT8 *)&im->image32[y][x];
out[0] = p[0];
out[1] = p[3];
}

static void
Expand Down Expand Up @@ -127,15 +116,6 @@ get_pixel_32B(Imaging im, int x, int y, void *color) {

/* store individual pixel */

static void
put_pixel(Imaging im, int x, int y, const void *color) {
if (im->image8) {
im->image8[y][x] = *((UINT8 *)color);
} else {
memcpy(&im->image32[y][x], color, sizeof(INT32));
}
}

static void
put_pixel_8(Imaging im, int x, int y, const void *color) {
im->image8[y][x] = *((UINT8 *)color);
Expand Down Expand Up @@ -186,8 +166,8 @@ ImagingAccessInit() {
/* populate access table */
ADD("1", get_pixel_8, put_pixel_8);
ADD("L", get_pixel_8, put_pixel_8);
ADD("LA", get_pixel, put_pixel);
ADD("La", get_pixel, put_pixel);
ADD("LA", get_pixel_32_2bands, put_pixel_32);
ADD("La", get_pixel_32_2bands, put_pixel_32);
ADD("I", get_pixel_32, put_pixel_32);
ADD("I;16", get_pixel_16L, put_pixel_16L);
ADD("I;16L", get_pixel_16L, put_pixel_16L);
Expand All @@ -197,7 +177,7 @@ ImagingAccessInit() {
ADD("I;32B", get_pixel_32B, put_pixel_32B);
ADD("F", get_pixel_32, put_pixel_32);
ADD("P", get_pixel_8, put_pixel_8);
ADD("PA", get_pixel, put_pixel);
ADD("PA", get_pixel_32_2bands, put_pixel_32);
ADD("RGB", get_pixel_32, put_pixel_32);
ADD("RGBA", get_pixel_32, put_pixel_32);
ADD("RGBa", get_pixel_32, put_pixel_32);
Expand Down

0 comments on commit 06e66f7

Please sign in to comment.