Clone in a terminal:
Commit 487dc33
Johan Mattsson - 2015-12-11T13:47:24+00:00
487dc336a9fe21b73f50b44f16bc40db42295346johan.mattsson.m@gmail.com

More raster image optimizations

Changed files (3)

Diff

diff --git a/libbirdfont/BackgroundImage.vala b/libbirdfont/BackgroundImage.valaindex da0d650..a50994d 100644--- a/libbirdfont/BackgroundImage.vala+++ b/libbirdfont/BackgroundImage.vala@@ -383,7 +383,7 @@ public class BackgroundImage { 		return get_scaled_backgrounds (); 	} 	-	public void preview_img_rotation_from_coordinate (double x, double y) {+	public void preview_img_rotation_from_coordinate (double x, double y, double view_zoom) { 		double rotation; 		ScaledBackgrounds backgounds; 		@@ -396,7 +396,8 @@ public class BackgroundImage { 			 			if (!high_contrast) { 				rotated = rotate ((ImageSurface) get_padded_image ());-				scaled = new ScaledBackgrounds.single_size (rotated, 1);+				// FIXME: y+				scaled = new ScaledBackgrounds.single_size (rotated, img_scale_x * view_zoom); 			} else { 				contrast_image = null; 			}@@ -491,11 +492,19 @@ public class BackgroundImage { 			part_offset_y /= img_scale_y / scaled.get_scale (); 			part_offset_y = -part_offset_y; -			double zoom = 1 / view_zoom;-			zoom /= img_scale_y / scaled.get_scale ();+			double part_allocation_width;+			double part_allocation_height;++			part_allocation_height = allocation.height;+			part_allocation_height /= view_zoom;+			part_allocation_height /= image_scale_x;++			part_allocation_width = allocation.width;+			part_allocation_width /= view_zoom;+			part_allocation_width /= image_scale_y; 			 			part = scaled.get_part (part_offset_x, part_offset_y, -				(int) (allocation.width * zoom), (int) (allocation.height * zoom)); +				(int) (part_allocation_width), (int) (part_allocation_height));   			scale_x = view_zoom * image_scale_x; 			scale_y = view_zoom * image_scale_y;diff --git a/libbirdfont/BackgroundTool.vala b/libbirdfont/BackgroundTool.valaindex b7376c9..36f6ec4 100644--- a/libbirdfont/BackgroundTool.vala+++ b/libbirdfont/BackgroundTool.vala@@ -157,7 +157,8 @@ public class BackgroundTool : Tool { 		BackgroundImage bg = (!) background_image; 		double xscale, yscale, dx, dy, xc, yc; 		double coordinate_x, coordinate_y;-+		double view_zoom;+		 		if (background_image == null) { 			return; 		}@@ -176,7 +177,8 @@ public class BackgroundTool : Tool { 		if (bg.selected_handle == 2) { 			coordinate_x = Glyph.path_coordinate_x (x); 			coordinate_y = Glyph.path_coordinate_y (y);-			bg.preview_img_rotation_from_coordinate (coordinate_x, coordinate_y);+			view_zoom = MainWindow.get_current_glyph ().view_zoom;+			bg.preview_img_rotation_from_coordinate (coordinate_x, coordinate_y, view_zoom); 		} 		 		if (bg.selected_handle == 1) {diff --git a/libbirdfont/ScaledImage.vala b/libbirdfont/ScaledImage.valaindex 95f6f9b..72161e1 100644--- a/libbirdfont/ScaledImage.vala+++ b/libbirdfont/ScaledImage.vala@@ -133,6 +133,14 @@ public class ScaledBackground : GLib.Object { 			start_y = 0; 		} +		if (stop_x > size) {+			stop_x = size;+		}++		if (stop_y > size) {+			stop_y = size;+		}+				 		int assembled_width = (int) ((stop_x - start_x) * image_width); 		int assembled_height = (int) ((stop_y - start_y) * image_height); 		

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112