Commit 487dc33
More raster image optimizations
Changed files (3)
modifiedlibbirdfont/BackgroundImage.valamodifiedlibbirdfont/BackgroundTool.valamodifiedlibbirdfont/ScaledImage.vala
Diff
@@ -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;@@ -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) {@@ -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);