The Birdfont Source Code
More raster image optimizations
These changes was commited to the Birdfont repository Fri, 11 Dec 2015 13:47:24 +0000.
Contributing
Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
More raster image optimizations
--- a/libbirdfont/BackgroundImage.vala
+++ b/libbirdfont/BackgroundImage.vala
@@ -383,7 +383,7 @@
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 @@
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 @@
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;
--- a/libbirdfont/BackgroundTool.vala
+++ b/libbirdfont/BackgroundTool.vala
@@ -157,7 +157,8 @@
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 @@
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) {
--- a/libbirdfont/ScaledImage.vala
+++ b/libbirdfont/ScaledImage.vala
@@ -133,6 +133,14 @@
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);