From ce96adf2fdd6425ab43a13506c0c629d68b91891 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Wed, 23 May 2012 22:49:41 -0700 Subject: Applied modified patch to add export messages. Partially fixes bug #43730. Fixed bugs: - https://launchpad.net/bugs/43730 (bzr r11407) --- src/helper/png-write.cpp | 56 +++++++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 31 deletions(-) (limited to 'src/helper/png-write.cpp') diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index 35fd5a62a..c43a207c8 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -4,6 +4,7 @@ * Authors: * Lauris Kaplinski * Whoever wrote this example in libpng documentation + * Peter Bostrom * Jon A. Cruz * Abhishek Sharma * @@ -379,43 +380,36 @@ static void hide_other_items_recursively(SPObject *o, GSList *list, unsigned dke } -/** - * Export the given document as a Portable Network Graphics (PNG) file. - * - * \return true if succeeded (or if no action was taken), false if an error occurred. - */ -bool sp_export_png_file (SPDocument *doc, gchar const *filename, - double x0, double y0, double x1, double y1, - unsigned long int width, unsigned long int height, double xdpi, double ydpi, - unsigned long bgcolor, - unsigned int (*status) (float, void *), - void *data, bool force_overwrite, - GSList *items_only) +ExportResult sp_export_png_file(SPDocument *doc, gchar const *filename, + double x0, double y0, double x1, double y1, + unsigned long int width, unsigned long int height, double xdpi, double ydpi, + unsigned long bgcolor, + unsigned int (*status) (float, void *), + void *data, bool force_overwrite, + GSList *items_only) { return sp_export_png_file(doc, filename, Geom::Rect(Geom::Point(x0,y0),Geom::Point(x1,y1)), width, height, xdpi, ydpi, bgcolor, status, data, force_overwrite, items_only); } -bool -sp_export_png_file(SPDocument *doc, gchar const *filename, - Geom::Rect const &area, - unsigned long width, unsigned long height, double xdpi, double ydpi, - unsigned long bgcolor, - unsigned (*status)(float, void *), - void *data, bool force_overwrite, - GSList *items_only) + +ExportResult sp_export_png_file(SPDocument *doc, gchar const *filename, + Geom::Rect const &area, + unsigned long width, unsigned long height, double xdpi, double ydpi, + unsigned long bgcolor, + unsigned (*status)(float, void *), + void *data, bool force_overwrite, + GSList *items_only) { - g_return_val_if_fail(doc != NULL, false); - g_return_val_if_fail(filename != NULL, false); - g_return_val_if_fail(width >= 1, false); - g_return_val_if_fail(height >= 1, false); - g_return_val_if_fail(!area.hasZeroArea(), false); + g_return_val_if_fail(doc != NULL, EXPORT_ERROR); + g_return_val_if_fail(filename != NULL, EXPORT_ERROR); + g_return_val_if_fail(width >= 1, EXPORT_ERROR); + g_return_val_if_fail(height >= 1, EXPORT_ERROR); + g_return_val_if_fail(!area.hasZeroArea(), EXPORT_ERROR); + if (!force_overwrite && !sp_ui_overwrite_file(filename)) { - /* Remark: We return true so as not to invoke an error dialog in case export is cancelled - by the user; currently this is safe because the callers only act when false is returned. - If this changes in the future we need better distinction of return types (e.g., use int) - */ - return true; + // aborted overwrite + return EXPORT_ABORTED; } doc->ensureUpToDate(); @@ -482,7 +476,7 @@ sp_export_png_file(SPDocument *doc, gchar const *filename, // Hide items, this releases arenaitem doc->getRoot()->invoke_hide(dkey); - return write_status; + return write_status ? EXPORT_OK : EXPORT_ERROR; } -- cgit v1.2.3 From f10048be170a45921ae8fc65ccd2588a9ad2897d Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Tue, 27 Aug 2013 12:32:55 -0400 Subject: Added viewBox implement document unit support. (bzr r12475.1.2) --- src/helper/png-write.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/helper/png-write.cpp') diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index c43a207c8..b8b815b4c 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -34,6 +34,7 @@ #include "preferences.h" #include "rdf.h" #include "display/cairo-utils.h" +#include "util/units.h" /* This is an example of how to use libpng to read and write PNG files. * The file libpng.txt is much more verbose then this. If you have not @@ -415,7 +416,7 @@ ExportResult sp_export_png_file(SPDocument *doc, gchar const *filename, doc->ensureUpToDate(); /* Calculate translation by transforming to document coordinates (flipping Y)*/ - Geom::Point translation = Geom::Point(-area[Geom::X][0], area[Geom::Y][1] - doc->getHeight()); + Geom::Point translation = Geom::Point(-area[Geom::X][0], area[Geom::Y][1] - doc->getHeight().value("px")); /* 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 -- cgit v1.2.3 From fd1ceb05805f20402606fd9fae1a048e0bca8e78 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Mon, 27 Jan 2014 13:19:30 -0500 Subject: Protect pdf and png exports from failure and output reasonalbe warnings. (bzr r12982) --- src/helper/png-write.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/helper/png-write.cpp') diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index b8b815b4c..a16fe8e12 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -142,7 +142,7 @@ sp_png_write_rgba_striped(SPDocument *doc, Inkscape::IO::dump_fopen_call(filename, "M"); fp = Inkscape::IO::fopen_utf8name(filename, "wb"); - g_return_val_if_fail(fp != NULL, false); + if(fp == NULL) return false; /* Create and initialize the png_struct with the desired error handler * functions. If you want to use the default stderr and longjump method, -- cgit v1.2.3 From d4ba8eaa4a621ac60d99a4aad7531d080cece2cd Mon Sep 17 00:00:00 2001 From: David Mathog Date: Sat, 8 Feb 2014 09:44:12 +0100 Subject: DrawingContext: change variable names ct to dc (bug #1272073) Fixed bugs: - https://launchpad.net/bugs/1272073 (bzr r13009) --- src/helper/png-write.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/helper/png-write.cpp') diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index a16fe8e12..a7ebe7423 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -335,14 +335,14 @@ sp_export_get_rows(guchar const **rows, void **to_free, int row, int num_rows, v cairo_surface_t *s = cairo_image_surface_create_for_data( px, CAIRO_FORMAT_ARGB32, ebp->width, num_rows, stride); - Inkscape::DrawingContext ct(s, bbox.min()); - ct.setSource(ebp->background); - ct.setOperator(CAIRO_OPERATOR_SOURCE); - ct.paint(); - ct.setOperator(CAIRO_OPERATOR_OVER); + Inkscape::DrawingContext dc(s, bbox.min()); + dc.setSource(ebp->background); + dc.setOperator(CAIRO_OPERATOR_SOURCE); + dc.paint(); + dc.setOperator(CAIRO_OPERATOR_OVER); /* Render */ - ebp->drawing->render(ct, bbox); + ebp->drawing->render(dc, bbox); cairo_surface_destroy(s); *to_free = px; -- cgit v1.2.3