Use memoryview instead of np.getbuffer. #210
np.getbuffer is not available in python3.
This commit is contained in:
parent
d2ba8a14b6
commit
63d203796b
1 changed files with 3 additions and 3 deletions
|
|
@ -1885,11 +1885,11 @@ class PaletteBox(Jp2kBox):
|
|||
if all(b == bps[0] for b in bps):
|
||||
# All components are the same. Writing is straightforward.
|
||||
if self.bits_per_component[0] <= 8:
|
||||
write_buffer = np.getbuffer(self.palette.astype(np.uint8))
|
||||
write_buffer = memoryview(self.palette.astype(np.uint8))
|
||||
elif self.bits_per_component[0] <= 16:
|
||||
write_buffer = np.getbuffer(self.palette.astype(np.uint16))
|
||||
write_buffer = memoryview(self.palette.astype(np.uint16))
|
||||
elif self.bits_per_component[0] <= 32:
|
||||
write_buffer = np.getbuffer(self.palette.astype(np.uint32))
|
||||
write_buffer = memoryview(self.palette.astype(np.uint32))
|
||||
fptr.write(write_buffer)
|
||||
else:
|
||||
# Not all the components are the same. More general, but much rarer
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue