rgbimage.py 文件源码

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

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


问题


面经


文章

微信
公众号

扫码关注公众号