summaryrefslogtreecommitdiffstats
path: root/filters/chalk/tiff/kis_tiff_converter.h
blob: 010ee3b717fbb2d7b359bb3e4d8a097a2acf0c4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
 *  Copyright (c) 2005-2006 Cyrille Berger <cberger@cberger.net>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program 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 General Public License for more details.
 *
 *  You should have received a copy of the GNU 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.
 */

#ifndef _KIS_TIFF_CONVERTER_H_
#define _KIS_TIFF_CONVERTER_H_

#include <stdio.h>
#include <tiffio.h>

#include <tqvaluevector.h>

#include <tdeio/job.h>

#include <kis_progress_subject.h>

#include "kis_types.h"
#include "kis_global.h"
#include "kis_annotation.h"
class KisDoc;
class KisUndoAdapter;

/**
 * Image import/export plugins can use these results to report about success or failure.
 */
enum KisImageBuilder_Result {
        KisImageBuilder_RESULT_FAILURE = -400,
        KisImageBuilder_RESULT_NOT_EXIST = -300,
        KisImageBuilder_RESULT_NOT_LOCAL = -200,
        KisImageBuilder_RESULT_BAD_FETCH = -100,
        KisImageBuilder_RESULT_INVALID_ARG = -50,
        KisImageBuilder_RESULT_OK = 0,
        KisImageBuilder_RESULT_PROGRESS = 1,
        KisImageBuilder_RESULT_EMPTY = 100,
        KisImageBuilder_RESULT_BUSY = 150,
        KisImageBuilder_RESULT_NO_URI = 200,
        KisImageBuilder_RESULT_UNSUPPORTED = 300,
        KisImageBuilder_RESULT_INTR = 400,
        KisImageBuilder_RESULT_PATH = 500,
        KisImageBuilder_RESULT_UNSUPPORTED_COLORSPACE = 600
};

struct KisTIFFOptions {
    TQ_UINT16 compressionType;
    TQ_UINT16 predictor;
    bool alpha;
    bool flatten;
    TQ_UINT16 jpegQuality;
    TQ_UINT16 deflateCompress;
    TQ_UINT16 faxMode;
    TQ_UINT16 pixarLogCompress;
};

class KisTIFFConverter : public KisProgressSubject {
        Q_OBJECT
  
    public:
        KisTIFFConverter(KisDoc *doc, KisUndoAdapter *adapter);
        virtual ~KisTIFFConverter();
    public:
        KisImageBuilder_Result buildImage(const KURL& uri);
        KisImageBuilder_Result buildFile(const KURL& uri, KisImageSP layer, KisTIFFOptions);
        /** Retrieve the constructed image
        */
        KisImageSP image();
    public slots:
        virtual void cancel();
    private:
        KisImageBuilder_Result decode(const KURL& uri);
        KisImageBuilder_Result readTIFFDirectory( TIFF* image);
    private:
        KisImageSP m_img;
        KisDoc *m_doc;
        KisUndoAdapter *m_adapter;
        bool m_stop;
        TDEIO::TransferJob *m_job;
};

#endif