[gnome-klotski] Replace pixbuf.scale_simple statement
- From: John Cheetham <jcheetham src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-klotski] Replace pixbuf.scale_simple statement
- Date: Wed, 14 Nov 2012 16:41:44 +0000 (UTC)
commit b8f1b922fa498448927b1ada9e30d9fa59d94f3c
Author: John Cheetham <developer johncheetham com>
Date: Wed Nov 14 16:33:44 2012 +0000
Replace pixbuf.scale_simple statement
When the board is made large the blocks can look blurred due to
scaling with scale_simple. I replaced this with
Rsvg.pixbuf_from_file_at_size and the blocks look sharper.
There are some deprecation warnings so this may need changing again
to use cairo.
src/puzzle-view.vala | 23 +++++++++++++++++++----
1 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/src/puzzle-view.vala b/src/puzzle-view.vala
index 27edd32..c720d35 100644
--- a/src/puzzle-view.vala
+++ b/src/puzzle-view.vala
@@ -21,6 +21,8 @@ public class PuzzleView : Gtk.DrawingArea
private double kx = 0;
private double ky = 0;
+ private string image_filepath = "";
+
private Puzzle? _puzzle = null;
public Puzzle? puzzle
{
@@ -58,11 +60,11 @@ public class PuzzleView : Gtk.DrawingArea
private void load_image ()
{
- var path = Path.build_filename (DATA_DIRECTORY, "gnome-klotski.svg", null);
+ image_filepath = Path.build_filename (DATA_DIRECTORY, "gnome-klotski.svg", null);
try
{
- tiles_image = Rsvg.pixbuf_from_file (path);
+ tiles_image = Rsvg.pixbuf_from_file (image_filepath);
}
catch (Error e)
{
@@ -74,7 +76,7 @@ public class PuzzleView : Gtk.DrawingArea
e.message);
dialog.run ();*/
stderr.printf ("%s %s\n", "Error in puzzle-view.vala load image:", e.message);
- stderr.printf ( "%s %s\n", "image path:", path);
+ stderr.printf ( "%s %s\n", "image path:", image_filepath);
Posix.exit (Posix.EXIT_FAILURE);
}
}
@@ -89,7 +91,20 @@ public class PuzzleView : Gtk.DrawingArea
tiles_pixbuf = null;
if (tiles_image != null)
- tiles_pixbuf = tiles_image.scale_simple(tile_size * THEME_TILE_SEGMENTS, tile_size * 2, Gdk.InterpType.BILINEAR);
+ {
+ int height = tile_size * 2;
+ int width = tile_size * THEME_TILE_SEGMENTS;
+
+ try
+ {
+ tiles_pixbuf = Rsvg.pixbuf_from_file_at_size (image_filepath, width, height);
+ }
+ catch (Error e)
+ {
+ stderr.printf ("%s %s\n", "Error in puzzle-view.vala draw function:", e.message);
+ }
+ }
+
}
var style = get_style_context ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]