2
* Copyright (c) 2009 Boudewijn Rempt <boud@valdyas.org>
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
#include "psd_export.h"
23
#include <kapplication.h>
25
#include <kpluginfactory.h>
27
#include <KoFilterChain.h>
28
#include <KoColorSpaceConstants.h>
31
#include <kis_image.h>
32
#include <kis_group_layer.h>
33
#include <kis_paint_layer.h>
34
#include <kis_paint_device.h>
36
#include "psd_saver.h"
38
class KisExternalLayer;
40
K_PLUGIN_FACTORY(ExportFactory, registerPlugin<psdExport>();)
41
K_EXPORT_PLUGIN(ExportFactory("kofficefilters"))
43
psdExport::psdExport(QObject *parent, const QVariantList &) : KoFilter(parent)
47
psdExport::~psdExport()
51
KoFilter::ConversionStatus psdExport::convert(const QByteArray& from, const QByteArray& to)
53
dbgFile <<"PSD export! From:" << from <<", To:" << to <<"";
55
if (from != "application/x-krita")
56
return KoFilter::NotImplemented;
58
KisDoc2 *output = dynamic_cast<KisDoc2*>(m_chain->inputDocument());
59
QString filename = m_chain->outputFile();
62
return KoFilter::CreationError;
65
if (filename.isEmpty()) return KoFilter::FileNotFound;
68
url.setPath(filename);
70
KisImageWSP image = output->image();
73
PSDSaver kpc(output, output->undoAdapter());
75
KisPaintDeviceSP pd = new KisPaintDevice(*image->projection());
76
KisPaintLayerSP l = new KisPaintLayer(image, "projection", OPACITY_OPAQUE, pd);
78
KisImageBuilder_Result res;
80
if ( (res = kpc.buildFile(url, l)) == KisImageBuilder_RESULT_OK) {
81
dbgFile <<"success !";
84
dbgFile <<" Result =" << res;
85
return KoFilter::InternalError;
88
#include <psd_export.moc>