Exemple #1
0
 def load_base(self, number):
     # Loads the base page (aka the page without the speech bubbles) from file.
     # We used to use a different system that allowed us to scale the svg to
     # the size of the page, but we can't do that from memory apparently so now
     # we just assume that the svg has the proper width and height setup
     pixbuf_loader = PixbufLoader.new_with_type('png')
     pixbuf_loader.write(self.comic.get_page_base(number))
     pixbuf_loader.close()
     pixbuf = pixbuf_loader.get_pixbuf()
     self.comic_base_pixbuf = pixbuf
Exemple #2
0
    def _get_pixbuf_from_bytes(self, width, height):
        loader = PixbufLoader.new()
        loader.set_size(width, height)
        loader.write(self._buffer)
        loader.close()

        animation = loader.get_animation()
        if animation.is_static_image():
            return animation.get_static_image()

        self.animated = True

        return animation
Exemple #3
0
 def load_translation(self, number):
     # Gets the translation svg and loads it to memory, I used to use a different method that allowed for scaling SVG
     # files to the proper resolution (rendering it again), however this method sucks ass and the authors should just
     # make their SVGs be the proper size.
     pixbuf_loader = PixbufLoader.new_with_type('svg')
     pixbuf_loader.write(
         self.comic.get_page_translation(self.comic_language, number))
     pixbuf_loader.close()
     pixbuf = pixbuf_loader.get_pixbuf()
     self.translated_comic_pixbuf = self.comic_base_pixbuf
     pixbuf.composite(self.translated_comic_pixbuf, 0, 0,
                      self.comic_base_pixbuf.props.width,
                      self.comic_base_pixbuf.props.height, 0, 0, 1.0, 1.0,
                      InterpType.HYPER, 254)
    def on_cambutton_clicked(self, widget):
        currentcam = self.camselect.get_active_text()

        camsfile = open('data/media/cameras.json', 'r')
        camdata = json.load(camsfile)

        for item in camdata:
            if item['name'] == currentcam:
                camurl = item['url']
                break

        image = urlopen(camurl)
        loader = PixbufLoader()
        loader.write(image.read())
        loader.close()

        self.camimage.set_from_pixbuf(loader.get_pixbuf())
Exemple #5
0
 def addPages(self, issue):
     zf = zipfile.ZipFile(issue.containing_directory + "/" + issue.file)
     for file_in_zip in zf.namelist():
         if ".jpg" in file_in_zip.lower() or ".png" in file_in_zip.lower():
             print(file_in_zip)
             loader = PixbufLoader()
             loader.write(zf.read(file_in_zip))
             loader.close()
             thumbnail = loader.get_pixbuf()
             h = thumbnail.get_height()
             w = thumbnail.get_width()
             r = h/w  # Preserve Aspect Ratio
             windowwidth= self.get_size()[0]
             pixbuf = Pixbuf.scale_simple(thumbnail, windowwidth, windowwidth*r, True)
             self.get_child().get_child().get_child().add(Gtk.Image.new_from_pixbuf(pixbuf))
Exemple #6
0
 def set_thumbnail_to_image(self, image_to_use):
     try:
         loader = PixbufLoader()
         loader.write(image_to_use)
         loader.close()
         thumbnail = loader.get_pixbuf()
         h = thumbnail.get_height()
         w = thumbnail.get_width()
         r = h/w  # Preserve Aspect Ratio
         pixbuf = Pixbuf.scale_simple(thumbnail, cover_width, cover_width*r, True)
         self.thumbnail = pixbuf
         return True
     except Exception:
         print(Exception)
         return False
Exemple #7
0
    def getAvatarPixbuf(avatarObj=None, size=None):
        GLib.idle_add(LoadingEventBus().start)  # start loading indicator
        if avatarObj is None:
            avatarObj = Github.getGithub().get_user()

        url = avatarObj.avatar_url

        client = httplib2.Http(cache=CACHE_DIR)
        resp, content = client.request(url)

        loader = PixbufLoader()
        loader.write(content)
        loader.close()

        GLib.idle_add(LoadingEventBus().stop)  # stop loading indicator
        if size is None:
            return loader.get_pixbuf()
        else:
            return loader.get_pixbuf().scale_simple(size[0], size[1], InterpType.BILINEAR)
    def on_cambutton_clicked(self, widget):
        currentcam = self.camselect.get_active_text()

        camsfile = open("data/media/cameras.json", "r")
        camdata = json.load(camsfile)

        for item in camdata:
            if item["name"] == currentcam:
                camurl = item["url"]
                break

        image = urlopen(camurl)
        loader = PixbufLoader()
        loader.write(image.read())
        loader.close()

        self.camimage.set_from_pixbuf(loader.get_pixbuf())
## Add a row with a stock icon (also easy)
iconpixbuf = Gtk.IconTheme.get_default().load_icon("folder", 16, 0)
treestore.append(None, [iconpixbuf, "data with a stock icon"])

## Add a row with an image from disk (still easy, uncomment if you have a suitable image file)
#loadedpixbuf = Pixbuf.new_from_file_at_size("../../img/logo.png", 125, 125) 
#treestore.append(None, [loadedpixbuf, "data with a custom image from disk"])

## Add a row with a flat-painted image (easy, but not always useful...)
from gi.repository import Gtk, Gdk
filledpixbuf = Pixbuf.new(Colorspace.RGB, True, 8, 16, 16)  ## In fact, it is RGBA
filledpixbuf.fill(0xff9922ff) 
treestore.append(None, [filledpixbuf, "data with a custom color filled image"])


px = PixbufLoader.new_with_type('pnm')
#color = b'\xee\xff\x2d'
#px.write(b'P6\n\n1 1\n255\n' + color)
#px.write(color)
iconpnm = b"""P2 24 7 25
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  3  3  3  3  0  0  7  7  7  7  0  0 11 11 11 11  0  0 15 15 15 15  0
0  3  0  0  0  0  0  7  0  0  0  0  0 11  0  0  0  0  0 15  0  0 15  0
0  3  3  3  0  0  0  7  7  7  0  0  0 11 11 11  0  0  0 15 15 15 15  0
0  3  0  0  0  0  0  7  0  0  0  0  0 11  0  0  0  0  0 15  0  0  0  0
0  3  0  0  0  0  0  7  7  7  7  0  0 11 11 11 11  0  0 15  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
"""
px.write(iconpnm)
px.close()
treestore.append(None, [px.get_pixbuf(), "data with an image loaded from a custom inline PNM file (tedious)"])
Exemple #10
0
## Add a row with a stock icon (also easy)
iconpixbuf = Gtk.IconTheme.get_default().load_icon("folder", 16, 0)
treestore.append(None, [iconpixbuf, "data with a stock icon"])

## Add a row with an image from disk (still easy, uncomment if you have a suitable image file)
#loadedpixbuf = Pixbuf.new_from_file_at_size("../../img/logo.png", 125, 125)
#treestore.append(None, [loadedpixbuf, "data with a custom image from disk"])

## Add a row with a flat-painted image (easy, but not always useful...)
from gi.repository import Gtk, Gdk
filledpixbuf = Pixbuf.new(Colorspace.RGB, True, 8, 16,
                          16)  ## In fact, it is RGBA
filledpixbuf.fill(0xff9922ff)
treestore.append(None, [filledpixbuf, "data with a custom color filled image"])

px = PixbufLoader.new_with_type('pnm')
#color = b'\xee\xff\x2d'
#px.write(b'P6\n\n1 1\n255\n' + color)
#px.write(color)
iconpnm = b"""P2 24 7 25
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  3  3  3  3  0  0  7  7  7  7  0  0 11 11 11 11  0  0 15 15 15 15  0
0  3  0  0  0  0  0  7  0  0  0  0  0 11  0  0  0  0  0 15  0  0 15  0
0  3  3  3  0  0  0  7  7  7  0  0  0 11 11 11  0  0  0 15 15 15 15  0
0  3  0  0  0  0  0  7  0  0  0  0  0 11  0  0  0  0  0 15  0  0  0  0
0  3  0  0  0  0  0  7  7  7  7  0  0 11 11 11 11  0  0 15  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
"""
px.write(iconpnm)
px.close()
treestore.append(None, [