mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 10:46:16 +03:00
F mode support
This commit is contained in:
parent
b6ad79d9f9
commit
bfdc599c28
|
@ -209,6 +209,24 @@ class _PyAccessI16_B(PyAccess):
|
|||
pixel.l = color >> 8
|
||||
pixel.r = color & 0xFF
|
||||
|
||||
|
||||
class _PyAccessF(PyAccess):
|
||||
""" 32 bit float access """
|
||||
def _post_init(self, *args, **kwargs):
|
||||
self.pixels = ffi.cast('float **', self.image32)
|
||||
|
||||
def get_pixel(self, x,y):
|
||||
return self.pixels[y][x]
|
||||
|
||||
def set_pixel(self, x,y, color):
|
||||
try:
|
||||
# not a tuple
|
||||
self.pixels[y][x] = color
|
||||
except:
|
||||
# tuple
|
||||
self.pixels[y][x] = color[0]
|
||||
|
||||
|
||||
mode_map = {'1': _PyAccess8,
|
||||
'L': _PyAccess8,
|
||||
'P': _PyAccess8,
|
||||
|
@ -221,6 +239,7 @@ mode_map = {'1': _PyAccess8,
|
|||
'RGBa': _PyAccess32_4,
|
||||
'RGBX': _PyAccess32_4,
|
||||
'CMYK': _PyAccess32_4,
|
||||
'F': _PyAccessF,
|
||||
}
|
||||
|
||||
if sys.byteorder == 'little':
|
||||
|
|
|
@ -41,13 +41,16 @@ def test_get_vs_c():
|
|||
_test_get_access(lena('1'))
|
||||
_test_get_access(lena('P'))
|
||||
#_test_get_access(lena('PA')) # PA -- how do I make a PA image???
|
||||
|
||||
_test_get_access(lena('F'))
|
||||
|
||||
im = Image.new('I;16', (10,10), 40000)
|
||||
_test_get_access(im)
|
||||
im = Image.new('I;16L', (10,10), 40000)
|
||||
_test_get_access(im)
|
||||
im = Image.new('I;16B', (10,10), 40000)
|
||||
_test_get_access(im)
|
||||
|
||||
|
||||
|
||||
def _test_set_access(im, color):
|
||||
""" Are we writing the correct bits into the image? """
|
||||
|
@ -70,7 +73,8 @@ def test_set_vs_c():
|
|||
_test_set_access(lena('1'), 255)
|
||||
_test_set_access(lena('P') , 128)
|
||||
##_test_set_access(i, (128,128)) #PA -- undone how to make
|
||||
|
||||
_test_set_access(lena('F'), 1024.0)
|
||||
|
||||
im = Image.new('I;16', (10,10), 40000)
|
||||
_test_set_access(im, 45000)
|
||||
im = Image.new('I;16L', (10,10), 40000)
|
||||
|
|
Loading…
Reference in New Issue
Block a user