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