def bytes2pixbuf(data, width=icon_size['width'], height=icon_size['height'], display_name=None):
"""
converts raw bytes into a GTK PixBug
args:
data (bytes): raw bytes
width (int): width of image
height (int): height of images
returns:
GtkPixbuf: a GTK Pixbuf
"""
loader = GdkPixbuf.PixbufLoader()
loader.set_size(width, height)
try:
loader.write(data)
loader.close()
except GLib.Error as e:
logger.error("can't process icon for {}: {}".format(display_name, str(e)))
else:
return loader.get_pixbuf()
评论列表
文章目录