def ensurearr(self, invalidate=True):
if self.darr is None:
if self.dpil is not None:
self.darr = np.fromstring(self.dpil.tostring("raw", "RGB", 0, -1), np.uint8).astype(np.float64)
self.darr = np.rollaxis(np.reshape(self.darr, (self.shape[1], self.shape[0], 3) ), 1)
elif self.dbuf is not None:
self.darr = np.fromstring(self.dbuf, np.uint8).astype(np.float64)
self.darr = np.delete(np.reshape(self.darr, (self.shape[1], self.shape[0], 4) ), 3, 2)
self.darr = np.rollaxis(np.flipud(self.darr), 1)
else:
raise ValueError("No source data for conversion to array")
self.rangearr = ( 0, 255.999 )
if invalidate:
self.dpil = None
self.dbuf = None
# -----------------------------------------------------------------
## This private helper function returns a 2-tuple containing the least and most significant 16-bit portion
# of the specified unsigned 32-bit integer value.
评论列表
文章目录