diff options
Diffstat (limited to 'src/helper')
| -rw-r--r-- | src/helper/pixbuf-ops.cpp | 2 | ||||
| -rw-r--r-- | src/helper/png-write.cpp | 21 |
2 files changed, 19 insertions, 4 deletions
diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp index c26d55b8b..3be63aa68 100644 --- a/src/helper/pixbuf-ops.cpp +++ b/src/helper/pixbuf-ops.cpp @@ -113,7 +113,7 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/, double padding = 1.0; Geom::Point origin(screen.min()[Geom::X], - screen.min()[Geom::Y]); + sp_document_height(doc) - screen[Geom::Y].extent() - screen.min()[Geom::Y]); origin[Geom::X] = origin[Geom::X] + (screen[Geom::X].extent() * ((1 - padding) / 2)); origin[Geom::Y] = origin[Geom::Y] + (screen[Geom::Y].extent() * ((1 - padding) / 2)); diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index 8eb9e27bf..b1c135db0 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -424,9 +424,24 @@ sp_export_png_file(SPDocument *doc, gchar const *filename, sp_document_ensure_up_to_date(doc); - /* Calculate translation */ - Geom::Point translation = Geom::Point(-area[Geom::X][0], -area[Geom::Y][0]); - + /* Calculate translation by transforming to document coordinates (flipping Y)*/ + Geom::Point translation = Geom::Point(-area[Geom::X][0], area[Geom::Y][1] - sp_document_height(doc)); + + /* This calculation is only valid when assumed that (x0,y0)= area.corner(0) and (x1,y1) = area.corner(2) + * 1) a[0] * x0 + a[2] * y1 + a[4] = 0.0 + * 2) a[1] * x0 + a[3] * y1 + a[5] = 0.0 + * 3) a[0] * x1 + a[2] * y1 + a[4] = width + * 4) a[1] * x0 + a[3] * y0 + a[5] = height + * 5) a[1] = 0.0; + * 6) a[2] = 0.0; + * + * (1,3) a[0] * x1 - a[0] * x0 = width + * a[0] = width / (x1 - x0) + * (2,4) a[3] * y0 - a[3] * y1 = height + * a[3] = height / (y0 - y1) + * (1) a[4] = -a[0] * x0 + * (2) a[5] = -a[3] * y1 + */ Geom::Matrix const affine(Geom::Translate(translation) * Geom::Scale(width / area.width(), |
