def ensurebuf(self, invalidate=True):
if self.dbuf is None:
if self.dpil is not None:
self.dbuf = self.dpil.tostring("raw", "RGBX", 0, 1)
elif self.darr is not None:
data = self.scaledpixelarray(0,255.999)
self.dbuf = np.dstack(( np.flipud(np.rollaxis(data,1)).astype(np.uint8),
np.zeros(self.shape[::-1],np.uint8) )).tostring()
else:
raise ValueError("No source data for conversion to buffer")
if invalidate:
self.dpil = None
self.darr = None
self.rangearr = None
## This private function ensures that there is a valid numpy array representation, converting from
# one of the other representations if necessary, and invalidating the other representations if requested.
评论列表
文章目录