rgbimage.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码
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.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号