Subversion Repositories Scribus

Rev

Rev 2025 | Rev 2053 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2004 fschmid 1
#ifndef SCIMAGE_H
2
#define SCIMAGE_H
3
 
4
#ifdef _MSC_VER
5
 #if (_MSC_VER >= 1200)
6
  #include "win-config.h"
7
 #endif
8
#else
9
 #include "config.h"
10
#endif
11
 
12
#include <setjmp.h>
13
#include <cstdlib>
14
#include <cmath>
15
#include <unistd.h>
16
#include <qimage.h>
17
#include <qstring.h>
18
#include <qdatastream.h>
19
#include <qmap.h>
20
#include <qvaluelist.h>
21
#include <qfile.h>
22
#include <qdir.h>
23
#include <qstringlist.h>
24
#include "fpointarray.h"
25
extern "C"
26
{
27
#define XMD_H           // shut JPEGlib up
28
#if defined(Q_OS_UNIXWARE)
29
#  define HAVE_BOOLEAN  // libjpeg under Unixware seems to need this
30
#endif
31
#include <jpeglib.h>
32
#include <jerror.h>
33
#undef HAVE_STDLIB_H
34
#ifdef const
35
#  undef const          // remove crazy C hackery in jconfig.h
36
#endif
37
}
38
#ifdef HAVE_TIFF
39
        #include <tiffio.h>
40
#endif
41
 
42
class ScImage : public QImage
43
{
44
public:
45
        ScImage();
46
        ScImage(QImage image);
47
        ScImage( int width, int height );
48
        ~ScImage() {};
2012 fschmid 49
        void initialize();
2004 fschmid 50
        QString ImageToTxt();
51
        QString ImageToCMYK();
52
        QString ImageToGray();
53
        QString ImageToCMYK_PS(int pl, bool pre);
54
        QString ImageToCMYK_PDF(bool pre);
55
        void Convert2JPG(QString fn, int Quality, bool isCMYK, bool isGray);
56
        QString MaskToTxt(bool PDF = true);
57
        QString MaskToTxt14();
2012 fschmid 58
        void swapRGBA();
2025 fschmid 59
        void createLowRes(double scale);
2004 fschmid 60
        void scaleImage(int width, int height);
61
        bool LoadPicture(QString fn, QString Prof, int rend, bool useEmbedded, bool useProf, int requestType, int gsRes, bool *realCMYK = 0);
62
        QString getAlpha(QString fn, bool PDF, bool pdf14);
63
 
64
        enum PSDColorMode
65
        {
66
                CM_BITMAP = 0,
67
                CM_GRAYSCALE = 1,
68
                CM_INDEXED = 2,
69
                CM_RGB = 3,
70
                CM_CMYK = 4,
71
                CM_MULTICHANNEL = 7,
72
                CM_DUOTONE = 8,
73
                CM_LABCOLOR = 9
74
        };
75
 
76
        struct PSDHeader
77
        {
78
                uint signature;
79
                ushort version;
80
                uchar reserved[6];
81
                ushort channel_count;
82
                uint height;
83
                uint width;
84
                ushort depth;
85
                ushort color_mode;
86
        };
87
 
88
struct PSDLayer
89
{
90
        QValueList<uint> channelLen;
91
        QValueList<int> channelType;
92
        int xpos;
93
        int ypos;
94
        int width;
95
        int height;
96
        ushort opacity;
97
        uchar clipping;
98
        uchar flags;
99
        QString layerName;
100
        QString blend;
101
        QImage thumb;
102
};
103
 
104
struct LoadRequest
105
{
106
        bool visible;
107
        ushort opacity;
108
        QString blend;
109
};
110
 
111
struct ImageInfoRecord
112
{
113
        int xres;
114
        int yres;
115
        int colorspace; /* 0 = RGB  1 = CMYK  2 = Grayscale */
116
        bool valid;
117
        bool isRequest;
118
        bool progressive;
2025 fschmid 119
        int lowResType; /* 0 = full Resolution, 1 = 72 dpi, 2 = 36 dpi */
120
        double lowResScale;
2004 fschmid 121
        QMap<QString, FPointArray> PDSpathData;
122
        QMap<int, LoadRequest> RequestProps;
123
        QString clipPath;
124
        QString usedPath;
125
        QString profileName;
126
        QValueList<PSDLayer> layerInfo;
127
} imgInfo;
128
 
129
private:
130
        bool IsValid( const PSDHeader & header );
131
        bool IsSupported( const PSDHeader & header );
132
        unsigned char INT_MULT ( unsigned char a, unsigned char b );
133
        void RGBTOHSV ( uchar& red, uchar& green, uchar& blue );
134
        void HSVTORGB ( uchar& hue, uchar& saturation, uchar& value );
135
        void RGBTOHLS ( uchar& red, uchar& green, uchar& blue );
136
        int HLSVALUE ( double n1, double n2, double hue );
137
        void HLSTORGB ( uchar& hue, uchar& lightness, uchar& saturation );
138
        bool loadLayerChannels( QDataStream & s, const PSDHeader & header, QValueList<PSDLayer> &layerInfo, uint layer, bool* firstLayer);
139
        bool loadLayer( QDataStream & s, const PSDHeader & header);
140
        QString getLayerString(QDataStream & s);
141
        QString getPascalString(QDataStream & s);
142
        void parseRessourceData( QDataStream & s, const PSDHeader & header, uint size);
143
        bool parseLayer( QDataStream & s, const PSDHeader & header);
144
        bool LoadPSD( QDataStream & s, const PSDHeader & header);
145
        bool marker_is_icc (jpeg_saved_marker_ptr marker);
146
        bool marker_is_photoshop (jpeg_saved_marker_ptr marker);
147
        bool read_jpeg_marker (UINT8 requestmarker, j_decompress_ptr cinfo, JOCTET **icc_data_ptr, unsigned int *icc_data_len);
2012 fschmid 148
        char* iccbuf;
149
        uint icclen;
2004 fschmid 150
};
151
#endif