[glom] Print Layout: Slight improvement to image scaling.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] Print Layout: Slight improvement to image scaling.
- Date: Tue, 30 Aug 2011 08:12:37 +0000 (UTC)
commit c429bc14b14c7765ae25c1067d61cc33e6f46a78
Author: Murray Cumming <murrayc murrayc com>
Date: Tue Aug 30 09:52:07 2011 +0200
Print Layout: Slight improvement to image scaling.
* glom/utility_widgets/canvas/canvas_image_movable.cc: scale_to_size():
Use the correct size in pixels to scale the image.
However, it is still overscaled and cropped due to goocanvas bug #657592 .
ChangeLog | 8 +++++++
.../utility_widgets/canvas/canvas_image_movable.cc | 21 +++++++++++++++++--
2 files changed, 26 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 69a2529..2086541 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-08-30 Murray Cumming <murrayc murrayc com>
+
+ Print Layout: Slight improvement to image scaling.
+
+ * glom/utility_widgets/canvas/canvas_image_movable.cc: scale_to_size():
+ Use the correct size in pixels to scale the image.
+ However, it is still overscaled and cropped due to goocanvas bug #657592 .
+
2011-08-29 Murray Cumming <murrayc murrayc com>
Print Layout: Allow editing of line width and color.
diff --git a/glom/utility_widgets/canvas/canvas_image_movable.cc b/glom/utility_widgets/canvas/canvas_image_movable.cc
index d823437..395c3d4 100644
--- a/glom/utility_widgets/canvas/canvas_image_movable.cc
+++ b/glom/utility_widgets/canvas/canvas_image_movable.cc
@@ -173,16 +173,31 @@ void CanvasImageMovable::scale_to_size()
double width = 0;
double height = 0;
get_width_height(width, height);
- //std::cout << "debug: " << G_STRFUNC << ": width=" << width << ", height=" << height << std::endl;
+ Goocanvas::Canvas* canvas = get_canvas();
+ if(!canvas)
+ {
+ std::cerr << G_STRFUNC << ": canvas is null" << std::endl;
+ return;
+ }
- if(width && height)
+ //Convert, because our canvas uses units (mm) but the pixbuf uses pixels:
+ double width_pixels = width;
+ double height_pixels = height;
+ canvas->convert_to_pixels(width_pixels, height_pixels);
+
+ if(width_pixels && height_pixels)
{
- Glib::RefPtr<Gdk::Pixbuf> pixbuf = Utils::image_scale_keeping_ratio(m_pixbuf, (int)height, (int)width);
+ Glib::RefPtr<Gdk::Pixbuf> pixbuf = Utils::image_scale_keeping_ratio(m_pixbuf, (int)height_pixels, (int)width_pixels);
property_pixbuf() = pixbuf;
}
//Make sure that the size stays the same even if the scaling wasn't exact:
set_width_height(width, height);
+
+ //TODO: Fix this goocanvas bug http://bugzilla.gnome.org/show_bug.cgi?id=657592,
+ //We can't work around it by forcing an extra scale in GooCanvasItem like so:
+ //property_scale_to_fit() = true;
+ //because that does not keep the aspect ratio.
}
void CanvasImageMovable::set_image_empty()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]