Ejemplo n.º 1
0
 def __init__(self, position, image):
     super(PillowImageDrawer, self).__init__()
     self.size = image.size
     self.img_size = self.size
     self.position = position
     self.angle = 0
     self.surface = image2surface(image)
Ejemplo n.º 2
0
 def __init__(self, position, image):
     super(PillowImageDrawer, self).__init__()
     self.size = image.size
     self.img_size = self.size
     self.position = position
     self.angle = 0
     self.surface = image2surface(image)
Ejemplo n.º 3
0
 def __init__(self, position, image):
     Drawer.__init__(self)
     self.size = image.size
     self.img_size = self.size
     self.position = position
     self.angle = 0
     self.surface = image2surface(image)
Ejemplo n.º 4
0
    def add_chunk(self, line, img_chunk):
        # big images take more time to draw
        # --> we resize it now
        img_size = fit(img_chunk.size, self.size)
        if (img_size[0] <= 0 or img_size[1] <= 0):
            return
        img_chunk = img_chunk.resize(img_size)

        surface = image2surface(img_chunk)
        self.surfaces.append((line * self.ratio, surface))
        self.on_tick()
Ejemplo n.º 5
0
    def add_chunk(self, line, img_chunk):
        # big images take more time to draw
        # --> we resize it now
        img_size = fit(img_chunk.size, self.size)
        if (img_size[0] <= 0 or img_size[1] <= 0):
            return
        img_chunk = img_chunk.resize(img_size)

        surface = image2surface(img_chunk)
        self.surfaces.append((line * self.ratio, surface))
        self.on_tick()
Ejemplo n.º 6
0
    def __init__(self, position):
        Animation.__init__(self)
        self.visible = True
        self.position = position
        self.size = (self.ICON_SIZE, self.ICON_SIZE)

        img = load_image("waiting.png")
        factor = self.ICON_SIZE / self.src_size
        img = img.resize((int(img.size[0] * factor), int(img.size[1] * factor)),
                         PIL.Image.ANTIALIAS)
        img.load()
        self.icon_surface = image2surface(img)
        self.frame = 1
        self.nb_frames = (
            (max(1, img.size[0] / self.ICON_SIZE)),
            (max(1, img.size[1] / self.ICON_SIZE)),
        )
Ejemplo n.º 7
0
    def __init__(self, position):
        Animation.__init__(self)
        self.visible = True
        self.position = position
        self.size = (self.ICON_SIZE, self.ICON_SIZE)

        img = load_image("waiting.png", pkg="paperwork.frontend")
        factor = self.ICON_SIZE / self.src_size
        img = img.resize((int(img.size[0] * factor),
                          int(img.size[1] * factor)),
                         PIL.Image.ANTIALIAS)
        img.load()
        self.icon_surface = image2surface(img)
        self.frame = 1
        self.nb_frames = (
            (max(1, img.size[0] / self.ICON_SIZE)),
            (max(1, img.size[1] / self.ICON_SIZE)),
        )
Ejemplo n.º 8
0
    def do(self):
        self.__cond.acquire()
        try:
            self.can_run = True
            self.emit('page-loading-start')
            self.__cond.wait(0.1)
        finally:
            self.__cond.release()

        try:
            if not self.can_run:
                return

            use_thumbnail = True
            if self.size[1] > (BasicPage.DEFAULT_THUMB_HEIGHT * 1.5):
                use_thumbnail = False
            if not self.can_run:
                return
            if not use_thumbnail:
                img = self.page.img
            else:
                img = self.page.get_thumbnail(BasicPage.DEFAULT_THUMB_WIDTH,
                                              BasicPage.DEFAULT_THUMB_HEIGHT)
            if not self.can_run:
                return
            if self.size != img.size:
                img = img.resize(self.size, PIL.Image.ANTIALIAS)
            if not self.can_run:
                return
            img.load()
            if not self.can_run:
                return
            self.emit('page-loading-img', image2surface(img))

        finally:
            self.emit('page-loading-done')