~ubuntu-branches/ubuntu/raring/calligra/raring-proposed

« back to all changes in this revision

Viewing changes to krita/plugins/formats/psd/psd_export.cc

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-01-15 17:26:10 UTC
  • mfrom: (1.1.17)
  • Revision ID: package-import@ubuntu.com-20130115172610-b193s9546hyssmym
Tags: 1:2.5.94-0ubuntu1
New upstream RC release

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include <kapplication.h>
24
24
#include <kdialog.h>
25
25
#include <kpluginfactory.h>
 
26
#include <kmessagebox.h>
26
27
 
 
28
#include <KoFilterManager.h>
27
29
#include <KoFilterChain.h>
28
30
#include <KoColorSpaceConstants.h>
29
31
 
55
57
    if (from != "application/x-krita")
56
58
        return KoFilter::NotImplemented;
57
59
 
58
 
    KisDoc2 *output = dynamic_cast<KisDoc2*>(m_chain->inputDocument());
 
60
    KisDoc2 *input = dynamic_cast<KisDoc2*>(m_chain->inputDocument());
59
61
    QString filename = m_chain->outputFile();
60
62
 
61
 
    if (!output)
62
 
        return KoFilter::CreationError;
63
 
 
 
63
    if (!input)
 
64
        return KoFilter::NoDocumentCreated;
 
65
 
 
66
 
 
67
    if (input->image()->width() > 30000 || input->image()->height() > 30000) {
 
68
        if (!m_chain->manager()->getBatchMode()) {
 
69
            KMessageBox::error(0, i18n("Unable to save to the Photoshop format.\n"
 
70
                                       "The Photoshop format only supports images that are smaller than 30000x3000 pixels."),
 
71
                               "Photoshop Export Error");
 
72
        }
 
73
        return KoFilter::InvalidFormat;
 
74
    }
64
75
 
65
76
    if (filename.isEmpty()) return KoFilter::FileNotFound;
66
77
 
67
78
    KUrl url;
68
79
    url.setPath(filename);
69
80
 
70
 
    KisImageWSP image = output->image();
71
 
    Q_CHECK_PTR(image);
72
 
 
73
 
    PSDSaver kpc(output);
74
 
 
75
 
    KisPaintDeviceSP pd = new KisPaintDevice(*image->projection());
76
 
    KisPaintLayerSP l = new KisPaintLayer(image, "projection", OPACITY_OPAQUE_U8, pd);
77
 
 
 
81
    PSDSaver kpc(input);
78
82
    KisImageBuilder_Result res;
79
83
 
80
 
    if ( (res = kpc.buildFile(url, l)) == KisImageBuilder_RESULT_OK) {
 
84
    if ((res = kpc.buildFile(url)) == KisImageBuilder_RESULT_OK) {
81
85
        dbgFile <<"success !";
82
86
        return KoFilter::OK;
83
87
    }