Python get pixbuf
12 Python code examples are found related to "
get pixbuf".
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
Example 1
Source File: utils.py From lplayer with MIT License | 6 votes |
def get_pixbuf_from_base64string(base64string): if base64string is None: return NOIMAGE raw_data = base64.b64decode(base64string.encode()) try: pixbuf_loader = GdkPixbuf.PixbufLoader.new_with_mime_type("image/jpeg") pixbuf_loader.write(raw_data) pixbuf_loader.close() pixbuf = pixbuf_loader.get_pixbuf() return pixbuf except Exception as e: print(e) try: pixbuf_loader = GdkPixbuf.PixbufLoader.new_with_mime_type("image/png") pixbuf_loader.write(raw_data) pixbuf_loader.close() pixbuf = pixbuf_loader.get_pixbuf() return pixbuf except Exception as e: print(e) return NOIMAGE
Example 2
Source File: layer_types.py From innstereo with GNU General Public License v2.0 | 6 votes |
def get_pixbuf(self): """ Returns a pixbuf with the current line-color. This method takes the current line-color hex-triplet and adds two characters for the transparency (Currently no transparency = ff). Then it created a Gdk.Pixbuf, fills it with the color and returns it. This method is called by the main window to create the colored squares for the layer view. """ line_color_alpha = int("0x{0}ff".format(self.props["line_color"][1:]), base=16) pixbuf_color = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, True, 8, 16, 16) pixbuf_color.fill(line_color_alpha) return pixbuf_color
Example 3
Source File: __init__.py From gtg with GNU General Public License v3.0 | 5 votes |
def get_pixbuf_from_icon_name(self, name, height): """ Helper function: returns a pixbuf of an icon given its name in the loaded icon theme @param name: the name of the icon @param height: the height of the returned pixbuf @param width: the width of the returned pixbuf @returns GdkPixbuf: a pixbuf containing the wanted icon, or None (if the icon is not present) """ return Gtk.IconTheme.get_default().load_icon(name, height, 0)
Example 4
Source File: IconLoader.py From pychess with GNU General Public License v3.0 | 5 votes |
def get_pixbuf(path, size=None): file = Gio.File.new_for_path(addDataPrefix(path)) if size is None: return GdkPixbuf.Pixbuf.new_from_stream(file.read(None), None) else: return GdkPixbuf.Pixbuf.new_from_stream_at_scale( file.read(None), size, size, True, None)
Example 5
Source File: gdkpixbuf2.py From pyglet with BSD 3-Clause "New" or "Revised" License | 5 votes |
def get_pixbuf(self): self._finish_load() pixbuf = gdkpixbuf.gdk_pixbuf_loader_get_pixbuf(self._loader) if pixbuf is None: raise ImageDecodeException('Failed to get pixbuf from loader') return GdkPixBuf(self, pixbuf)
Example 6
Source File: pref_edit.py From NativeCAM with GNU General Public License v2.0 | 5 votes |
def get_pixbuf(self, icon, size) : if size < 16 : size = 16 imgfile = os.path.join(self.path, 'graphics', icon) if imgfile is not None : try : return gdk.pixbuf_new_from_file_at_size(imgfile, size, size) except gdk.PixbufError as err : print(err) return None
Example 7
Source File: gnomecast.py From gnomecast with GNU General Public License v3.0 | 5 votes |
def get_logo_pixbuf(self, width=200, color=None): svg = LOGO_SVG if color: svg = svg.replace('#aaaaaa', color) f = Gio.MemoryInputStream.new_from_bytes(GLib.Bytes.new(svg.encode())) preserve_aspect_ratio = True pixbuf = GdkPixbuf.Pixbuf.new_from_stream(f, None) return pixbuf
Example 8
Source File: weatherwidget.py From my-weather-indicator with MIT License | 5 votes |
def get_surface_from_pixbuf(pixbuf): surface = cairo.ImageSurface( cairo.FORMAT_ARGB32, pixbuf.get_width(), pixbuf.get_height()) micairo = cairo.Context(surface) micairo.save() Gdk.cairo_set_source_pixbuf(micairo, pixbuf, 0, 0) micairo.paint() micairo.restore() return surface
Example 9
Source File: image.py From drawing with GNU General Public License v3.0 | 5 votes |
def get_mini_pixbuf(self, preview_size): mpb_width = self.get_pixbuf_width() mpb_height = self.get_pixbuf_height() if mpb_height > mpb_width: mw = preview_size * (mpb_width/mpb_height) mh = preview_size else: mw = preview_size mh = preview_size * (mpb_height/mpb_width) return self.main_pixbuf.scale_simple(mw, mh, GdkPixbuf.InterpType.TILES)
Example 10
Source File: abstract_tool.py From drawing with GNU General Public License v3.0 | 5 votes |
def get_selection_pixbuf(self): return self.get_selection().get_pixbuf() ############################################################################ # Image management #########################################################
Example 11
Source File: applications.py From zim-desktop-wiki with GNU General Public License v2.0 | 5 votes |
def get_pixbuf(self, size): '''Get the application icon as a C{GdkPixbuf.Pixbuf}. @param size: the icon size as gtk constant @returns: a pixbuf object or C{None} ''' icon = self['Desktop Entry'].get('Icon', None) if not icon: return None if isinstance(icon, File): icon = icon.path w, h = strip_boolean_result(Gtk.icon_size_lookup(size)) if '/' in icon or '\\' in icon: if os.path.isfile(icon): return GdkPixbuf.Pixbuf.new_from_file_at_size(icon, w, h) else: return None else: theme = Gtk.IconTheme.get_default() try: pixbuf = theme.load_icon(icon, w, 0) except Exception as error: #~ logger.exception('Foo') return None return pixbuf
Example 12
Source File: util.py From python-eduvpn-client with GNU General Public License v3.0 | 5 votes |
def get_pixbuf(logo=None): # type: (Optional[str]) -> Tuple[GdkPixbuf.Pixbuf, GdkPixbuf.Pixbuf] if not logo: logo = path.join(get_prefix(), 'share/eduvpn/eduvpn.png') small = GdkPixbuf.Pixbuf.new_from_file_at_scale(logo, icon_size['width'], icon_size['height'], True) big = GdkPixbuf.Pixbuf.new_from_file_at_scale(logo, icon_size['width'] * 2, icon_size['height'] * 2, True) return small, big