Change get_pixel to be specific to images with 2 bands

This commit is contained in:
Andrew Murray 2023-07-21 21:08:20 +10:00
parent 7ffad80294
commit 577a4d8bf8

View File

@ -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
@ -177,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_32);
ADD("La", get_pixel, put_pixel_32);
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);
@ -188,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_32);
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);