diff --git a/plugins/impex/ora/ora_converter.cc b/plugins/impex/ora/ora_converter.cc index 5a717fa8c5..9ed7087369 100644 --- a/plugins/impex/ora/ora_converter.cc +++ b/plugins/impex/ora/ora_converter.cc @@ -1,121 +1,121 @@ /* * Copyright (c) 2007 Cyrille Berger * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "ora_converter.h" #include #include #include #include - +#include #include #include #include #include #include #include #include "kis_png_converter.h" #include "ora_load_context.h" #include "ora_save_context.h" OraConverter::OraConverter(KisDocument *doc) : m_doc(doc) , m_stop(false) { } OraConverter::~OraConverter() { } KisImageBuilder_Result OraConverter::buildImage(const QString &filename) { KoStore* store = KoStore::createStore(filename, KoStore::Read, "image/openraster", KoStore::Zip); if (!store) { delete store; return KisImageBuilder_RESULT_FAILURE; } OraLoadContext olc(store); KisOpenRasterStackLoadVisitor orslv(m_doc->createUndoStore(), &olc); orslv.loadImage(); m_image = orslv.image(); m_activeNodes = orslv.activeNodes(); delete store; return KisImageBuilder_RESULT_OK; } KisImageWSP OraConverter::image() { return m_image; } vKisNodeSP OraConverter::activeNodes() { return m_activeNodes; } KisImageBuilder_Result OraConverter::buildFile(const QString &filename, KisImageWSP image, vKisNodeSP activeNodes) { // Open file for writing KoStore* store = KoStore::createStore(filename, KoStore::Write, "image/openraster", KoStore::Zip); if (!store) { return KisImageBuilder_RESULT_FAILURE; } OraSaveContext osc(store); KisOpenRasterStackSaveVisitor orssv(&osc, activeNodes); image->rootLayer()->accept(orssv); if (store->open("Thumbnails/thumbnail.png")) { QSize previewSize = image->bounds().size(); previewSize.scale(QSize(256,256), Qt::KeepAspectRatio); QImage preview = image->convertToQImage(previewSize, 0); KoStoreDevice io(store); if (io.open(QIODevice::WriteOnly)) { preview.save(&io, "PNG"); } io.close(); store->close(); } KisPaintDeviceSP dev = image->projection(); if (!KisPNGConverter::isColorSpaceSupported(dev->colorSpace())) { dev = new KisPaintDevice(*dev.data()); KUndo2Command *cmd = dev->convertTo(KoColorSpaceRegistry::instance()->rgb8()); delete cmd; } KisPNGConverter::saveDeviceToStore("mergedimage.png", image->bounds(), image->xRes(), image->yRes(), dev, store); delete store; return KisImageBuilder_RESULT_OK; } void OraConverter::cancel() { m_stop = true; }