示例#1
0
    def __init__(self, size=None, img=None, unit=1):
        self.unit = t2(unit)

        if img is not None:
            iw, ih = img.size
            ux, uy = self.unit
            assert iw % ux == 0, 'image width is not divisible by unit'
            assert ih % uy == 0, 'image height is not divisible by unit'
            self.size = (iw // ux, ih // uy)
            self._img = img
        else:
            px_size = tuple(u * s for u, s in zip(self.unit, size))
            self.size = size
            self._img = img or CachedImage.blank(px_size)

        self.px_size = self._img.size
示例#2
0
    def __init__(self, size=None, img=None, unit=1):
        self.unit = t2(unit)

        if img is not None:
            iw, ih = img.size
            ux, uy = self.unit
            assert iw % ux == 0, 'image width is not divisible by unit'
            assert ih % uy == 0, 'image height is not divisible by unit'
            self.size = (iw // ux, ih // uy)
            self._img = img
        else:
            px_size = tuple(u * s for u,s in zip(self.unit, size))
            self.size = size
            self._img = img or CachedImage.blank(px_size)

        self.px_size = self._img.size
示例#3
0
def _load_image(full_path, unit):
    if full_path not in LOAD_CACHE:
        LOAD_CACHE[full_path] = Image(img=CachedImage.open(full_path),
                                      unit=unit or 1)
    return LOAD_CACHE[full_path]
示例#4
0
def _load_image(full_path, unit):
    if full_path not in LOAD_CACHE:
        LOAD_CACHE[full_path] = Image(img=CachedImage.open(full_path), unit=unit or 1)
    return LOAD_CACHE[full_path]
示例#5
0
 def sheet(img_offsets, size=None, unit=1):
     img_offsets = [(i.raw(), off) for i,off in img_offsets]
     new_img = CachedImage.sheet(img_offsets, size)
     return Image(img=new_img, unit=unit)
示例#6
0
 def open(path):
     return Image(img=CachedImage.from_raw(PIL.Image.open(path)))
示例#7
0
 def from_raw(img):
     return Image(img=CachedImage.from_raw(img))
示例#8
0
 def flatten(self):
     w, h = self.px_size
     new_img = CachedImage.sheet(
             [(self._frames[i].raw(), (i * w, 0)) for i in range(self.length)],
             (self.length * w, h))
     return Image(img=new_img, unit=self.unit)