mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 10:46:16 +03:00
Merge pull request #7296 from radarhere/access
This commit is contained in:
commit
06e66f7f5c
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user