// SPDX-License-Identifier: GPL-2.0-or-later /* * An internal raster export which passes the generated PNG output * to an external file. In the future this module could host more of * the PNG generation code that isn't needed for other raster export options. * * Authors: * Martin Owens * * Copyright (C) 2021 Authors * * Released under GNU GPL v2+, read the file 'COPYING' for more information. */ #include "png-output.h" #include #include #include #include #include #include "clear-n_.h" namespace Inkscape { namespace Extension { namespace Internal { void PngOutput::export_raster(Inkscape::Extension::Output * /*module*/, const SPDocument * /*doc*/, std::string const &png_file, gchar const *filename) { // We want to move the png file to the new location Glib::RefPtr input_fn = Gio::File::create_for_path(png_file); Glib::RefPtr output_fn = Gio::File::create_for_path(filename); try { // This file must be copied because the permissions must be created // based on it's target location and not the temp directory. input_fn->copy(output_fn, Gio::FILE_COPY_OVERWRITE | Gio::FILE_COPY_TARGET_DEFAULT_PERMS); } catch (const Gio::Error& e) { std::cerr << "Moving resource " << png_file << " to " << filename << " failed: " << e.what().raw() << std::endl; } } void PngOutput::init() { // clang-format off Inkscape::Extension::build_from_mem( "\n" "" N_("Portable Network Graphic") "\n" "" SP_MODULE_KEY_RASTER_PNG "\n" "false" "" "" // First because it's the default option "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" // First because it's default (and broken) "" "" "" "" "0.0" "2" "\n" ".png\n" "image/png\n" "" N_("Portable Network Graphic (*.png)") "\n" "" N_("Default raster graphic export") "\n" "\n" "", new PngOutput()); // clang-format on } } // namespace Internal } // namespace Extension } // namespace Inkscape /* Local Variables: mode:c++ c-file-style:"stroustrup" c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :