summaryrefslogtreecommitdiff
path: root/src/images/image.vala
diff options
context:
space:
mode:
authorJörg Frings-Fürst <jff@merkur>2014-07-23 11:40:09 +0200
committerJörg Frings-Fürst <jff@merkur>2014-07-23 11:40:09 +0200
commit6dbb3a7c8f19291de04fc898cef243164fba1ee6 (patch)
tree773ada7d8adb1d3e3ffdd39a3c32f6ea116be867 /src/images/image.vala
parent4aad8c4dc20299a461cadfce208ef42ea7758c81 (diff)
parent6edfb34cb3eee958e392a433ae9ac4f240279d09 (diff)
Merge tag 'upstream/0.5.5'
Upstream version 0.5.5
Diffstat (limited to 'src/images/image.vala')
-rw-r--r--src/images/image.vala10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/images/image.vala b/src/images/image.vala
index 1d9674b..197523b 100644
--- a/src/images/image.vala
+++ b/src/images/image.vala
@@ -134,6 +134,7 @@ public class Image : GLib.Object {
warning("Failed to load " + filename + "!");
this.surface = new Cairo.ImageSurface(Cairo.Format.ARGB32, width, height);
}
+
} catch (GLib.Error e) {
message("Error loading image file: %s", e.message);
this.surface = new Cairo.ImageSurface(Cairo.Format.ARGB32, width, height);
@@ -167,8 +168,11 @@ public class Image : GLib.Object {
/////////////////////////////////////////////////////////////////////
public Gdk.Pixbuf to_pixbuf() {
- var pixbuf = new Gdk.Pixbuf.from_data(surface.get_data(), Gdk.Colorspace.RGB, true, 8,
- width(), height(), surface.get_stride(), null);
+ if (this.surface == null || this.surface.get_data().length <= 0)
+ return new Gdk.Pixbuf(Gdk.Colorspace.RGB, true, 8, 1, 1);
+
+ var pixbuf = new Gdk.Pixbuf.from_data(this.surface.get_data(), Gdk.Colorspace.RGB, true, 8,
+ width(), height(), this.surface.get_stride(), null);
pixbuf = pixbuf.copy();
@@ -180,7 +184,7 @@ public class Image : GLib.Object {
*(p + i) = *(p + i + 2);
*(p + i + 2) = tmp;
}
-
+
return pixbuf;
}