diff options
author | Gonzalo Odiard <godiard@gmail.com> | 2013-03-06 17:30:50 (GMT) |
---|---|---|
committer | Gonzalo Odiard <godiard@gmail.com> | 2013-03-06 17:36:07 (GMT) |
commit | 16495674277dfed5241d0bf6711d475765e731a8 (patch) | |
tree | 16e41e00055a38d1d3bcb721b665a851ea9f3075 | |
parent | df0ec0fced87fe7d472706970ef074c38df1617a (diff) |
Use GdkPixbuf to open files - SL #4418
Instead of use a cairo.ImageSurface, use a GdkPixbuf to load
files and paint it over the ImageSurface. In this way we can open
more file types than png, like in previous Paint versions.
This solves opening a clipboard object, like in the ticket SL #4418
Also the cairo developers said the ImageSurface.create_from_png method
is not designed to use in production but only to help in testing.
This patch is a simpler version based in the work of Manuel Kauffman.
Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
-rw-r--r-- | Area.py | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -241,8 +241,13 @@ class Area(Gtk.DrawingArea): return style.zoom(44) def load_from_file(self, file_path): - self.drawing_canvas_data = \ - cairo.ImageSurface.create_from_png(file_path) + # load using a pixbuf to be able to read different formats + loaded_pxb = GdkPixbuf.Pixbuf.new_from_file(file_path) + self.drawing_canvas_data = cairo.ImageSurface(cairo.FORMAT_ARGB32, + loaded_pxb.get_width(), loaded_pxb.get_height()) + ctx = cairo.Context(self.drawing_canvas_data) + Gdk.cairo_set_source_pixbuf(ctx, loaded_pxb, 0, 0) + ctx.paint() def setup(self, width, height): """Configure the Area object.""" |