mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Support accessing I;16N pixels
This commit is contained in:
parent
8cfc25618f
commit
a0e1608f4f
|
@ -266,15 +266,10 @@ class TestCffi(AccessTest):
|
|||
# self._test_get_access(hopper('PA')) # PA -- how do I make a PA image?
|
||||
self._test_get_access(hopper("F"))
|
||||
|
||||
im = Image.new("I;16", (10, 10), 40000)
|
||||
self._test_get_access(im)
|
||||
im = Image.new("I;16L", (10, 10), 40000)
|
||||
self._test_get_access(im)
|
||||
im = Image.new("I;16B", (10, 10), 40000)
|
||||
self._test_get_access(im)
|
||||
for mode in ("I;16", "I;16L", "I;16B", "I;16N", "I"):
|
||||
im = Image.new(mode, (10, 10), 40000)
|
||||
self._test_get_access(im)
|
||||
|
||||
im = Image.new("I", (10, 10), 40000)
|
||||
self._test_get_access(im)
|
||||
# These don't actually appear to be modes that I can actually make,
|
||||
# as unpack sets them directly into the I mode.
|
||||
# im = Image.new('I;32L', (10, 10), -2**10)
|
||||
|
@ -313,15 +308,10 @@ class TestCffi(AccessTest):
|
|||
# self._test_set_access(i, (128, 128)) #PA -- undone how to make
|
||||
self._test_set_access(hopper("F"), 1024.0)
|
||||
|
||||
im = Image.new("I;16", (10, 10), 40000)
|
||||
self._test_set_access(im, 45000)
|
||||
im = Image.new("I;16L", (10, 10), 40000)
|
||||
self._test_set_access(im, 45000)
|
||||
im = Image.new("I;16B", (10, 10), 40000)
|
||||
self._test_set_access(im, 45000)
|
||||
for mode in ("I;16", "I;16L", "I;16B", "I;16N", "I"):
|
||||
im = Image.new(mode, (10, 10), 40000)
|
||||
self._test_set_access(im, 45000)
|
||||
|
||||
im = Image.new("I", (10, 10), 40000)
|
||||
self._test_set_access(im, 45000)
|
||||
# im = Image.new('I;32L', (10, 10), -(2**10))
|
||||
# self._test_set_access(im, -(2**13)+1)
|
||||
# im = Image.new('I;32B', (10, 10), 2**10)
|
||||
|
|
|
@ -318,6 +318,7 @@ mode_map = {
|
|||
"1": _PyAccess8,
|
||||
"L": _PyAccess8,
|
||||
"P": _PyAccess8,
|
||||
"I;16N": _PyAccessI16_N,
|
||||
"LA": _PyAccess32_2,
|
||||
"La": _PyAccess32_2,
|
||||
"PA": _PyAccess32_2,
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
/* use make_hash.py from the pillow-scripts repository to calculate these values */
|
||||
#define ACCESS_TABLE_SIZE 27
|
||||
#define ACCESS_TABLE_HASH 3078
|
||||
#define ACCESS_TABLE_HASH 33051
|
||||
|
||||
static struct ImagingAccessInstance access_table[ACCESS_TABLE_SIZE];
|
||||
|
||||
|
@ -92,6 +92,12 @@ get_pixel_16B(Imaging im, int x, int y, void *color) {
|
|||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
get_pixel_16(Imaging im, int x, int y, void *color) {
|
||||
UINT8 *in = (UINT8 *)&im->image[y][x + x];
|
||||
memcpy(color, in, sizeof(UINT16));
|
||||
}
|
||||
|
||||
static void
|
||||
get_pixel_32(Imaging im, int x, int y, void *color) {
|
||||
memcpy(color, &im->image32[y][x], sizeof(INT32));
|
||||
|
@ -186,6 +192,7 @@ ImagingAccessInit() {
|
|||
ADD("I;16", get_pixel_16L, put_pixel_16L);
|
||||
ADD("I;16L", get_pixel_16L, put_pixel_16L);
|
||||
ADD("I;16B", get_pixel_16B, put_pixel_16B);
|
||||
ADD("I;16N", get_pixel_16, put_pixel_16L);
|
||||
ADD("I;32L", get_pixel_32L, put_pixel_32L);
|
||||
ADD("I;32B", get_pixel_32B, put_pixel_32B);
|
||||
ADD("F", get_pixel_32, put_pixel_32);
|
||||
|
|
Loading…
Reference in New Issue
Block a user