index ee17e7079e639a724607ec37e2d45609f088a3c8..d3fe2771ff8d07970153b3b1427879a0d08a0977 100644 (file)
--- a/src/helper/png-write.cpp
+++ b/src/helper/png-write.cpp
-#define __SP_PNG_WRITE_C__
-
/*
* PNG file format utilities
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* Whoever wrote this example in libpng documentation
+ * Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) 1999-2002 authors
*
png_uint_32 r;
g_return_val_if_fail(filename != NULL, false);
+ g_return_val_if_fail(data != NULL, false);
/* open the file */
/**
* Hide all items that are not listed in list, recursively, skipping groups and defs.
*/
-static void
-hide_other_items_recursively(SPObject *o, GSList *list, unsigned dkey)
+static void hide_other_items_recursively(SPObject *o, GSList *list, unsigned dkey)
{
if ( SP_IS_ITEM(o)
&& !SP_IS_DEFS(o)
&& !SP_IS_GROUP(o)
&& !g_slist_find(list, o) )
{
- sp_item_invoke_hide(SP_ITEM(o), dkey);
+ SP_ITEM(o)->invoke_hide(dkey);
}
// recurse
if (!g_slist_find(list, o)) {
- for (SPObject *child = sp_object_first_child(o) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
+ for ( SPObject *child = o->firstChild() ; child; child = child->getNext() ) {
hide_other_items_recursively(child, list, dkey);
}
}
g_return_val_if_fail(height >= 1, false);
g_return_val_if_fail(!area.hasZeroArea(), false);
- //Make relative paths absolute, if possible:
- gchar *path = 0;
- if (!g_path_is_absolute(filename) && doc->uri) {
- gchar *dirname = g_path_get_dirname(doc->uri);
- if (dirname) {
- path = g_build_filename(dirname, filename, NULL);
- g_free(dirname);
- }
- }
- if (!path) {
- path = g_strdup(filename);
- }
-
- if (!force_overwrite && !sp_ui_overwrite_file(path)) {
+ 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;
}
- // export with maximum blur rendering quality
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- int saved_quality = prefs->getInt("/options/blurquality/value", 0);
- prefs->setInt("/options/blurquality/value", 2);
- int saved_filter_quality = prefs->getInt("/options/filterquality/value", 0);
- prefs->setInt("/options/filterquality/value", 2);
-
- sp_document_ensure_up_to_date(doc);
+ doc->ensureUpToDate();
/* 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));
+ Geom::Point translation = Geom::Point(-area[Geom::X][0], area[Geom::Y][1] - doc->getHeight());
/* 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
/* Create new arena */
NRArena *const arena = NRArena::create();
- unsigned const dkey = sp_item_display_key_new(1);
+ // export with maximum blur rendering quality
+ nr_arena_set_renderoffscreen(arena);
+ unsigned const dkey = SPItem::display_key_new(1);
/* Create ArenaItems and set transform */
- ebp.root = sp_item_invoke_show(SP_ITEM(sp_document_root(doc)), arena, dkey, SP_ITEM_SHOW_DISPLAY);
+ ebp.root = SP_ITEM(doc->getRoot())->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY);
nr_arena_item_set_transform(NR_ARENA_ITEM(ebp.root), affine);
// We show all and then hide all items we don't want, instead of showing only requested items,
// because that would not work if the shown item references something in defs
if (items_only) {
- hide_other_items_recursively(sp_document_root(doc), items_only, dkey);
+ hide_other_items_recursively(doc->getRoot(), items_only, dkey);
}
ebp.status = status;
if ((width < 256) || ((width * height) < 32768)) {
ebp.px = nr_pixelstore_64K_new(FALSE, 0);
ebp.sheight = 65536 / (4 * width);
- write_status = sp_png_write_rgba_striped(doc, path, width, height, xdpi, ydpi, sp_export_get_rows, &ebp);
+ write_status = sp_png_write_rgba_striped(doc, filename, width, height, xdpi, ydpi, sp_export_get_rows, &ebp);
nr_pixelstore_64K_free(ebp.px);
} else {
ebp.sheight = 64;
- ebp.px = g_new(guchar, 4 * ebp.sheight * width);
- write_status = sp_png_write_rgba_striped(doc, path, width, height, xdpi, ydpi, sp_export_get_rows, &ebp);
+ ebp.px = g_try_new(guchar, 4 * ebp.sheight * width);
+ write_status = sp_png_write_rgba_striped(doc, filename, width, height, xdpi, ydpi, sp_export_get_rows, &ebp);
g_free(ebp.px);
}
// Hide items, this releases arenaitem
- sp_item_invoke_hide(SP_ITEM(sp_document_root(doc)), dkey);
+ SP_ITEM(doc->getRoot())->invoke_hide(dkey);
/* Free arena */
nr_object_unref((NRObject *) arena);
- // restore saved blur and filter quality
- prefs->setInt("/options/blurquality/value", saved_quality);
- prefs->setInt("/options/filterquality/value", saved_filter_quality);
-
- g_free(path);
-
return write_status;
}
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :