forked from Boms/photoqt-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfileformats.h
352 lines (238 loc) · 7.4 KB
/
fileformats.h
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
#ifndef FILEFORMATS_H
#define FILEFORMATS_H
#include <QObject>
class FileFormats {
private:
bool readonly;
public:
// Per default enabled image formats
QStringList formatsQtEnabled;
QStringList formatsGmEnabled;
QStringList formatsExtrasEnabled;
void setDefaultFormats() {
formatsQtEnabled.clear();
formatsGmEnabled.clear();
/******************************
***** 14 FORMATS WORKING *****
******************************/
formatsQtEnabled << "*.bmp" // Microsoft Windows bitmap
<< "*.bitmap"
<< "*.dds" // Direct Draw Surface
<< "*.gif" // CompuServe Graphics Interchange Format
<< "*.tif" // Tagged Image File Format
<< "*.tiff"
<< "*.jpeg2000" // JPEG-2000 Code Stream Syntax
<< "*.jp2"
<< "*.jpc"
<< "*.j2k"
<< "*.jpf"
<< "*.jpx"
<< "*.jpm"
<< "*.mj2"
<< "*.mng" // Multiple-image Network Graphics
<< "*.ico" // Microsoft icon
<< "*.icns"
<< "*.jpeg" // Joint Photographic Experts Group JFIF format
<< "*.jpg"
<< "*.png" // Portable Network Graphics
<< "*.pbm" // Portable bitmap format (black and white)
<< "*.pgm" // Portable graymap format (gray scale)
<< "*.ppm" // Portable pixmap format (color)
<< "*.svg" // Scalable Vector Graphics
<< "*.svgz"
<< "*.wbmp" // Wireless bitmap
<< "*.webp"
<< "*.xbm" // X Windows system bitmap, black and white only
<< "*.xpm"; // X Windows system pixmap
formatsExtrasEnabled << "**.psb"
<< "**.psd"
<< "**.xcf";
#ifdef GM
/**************************************
***** 49 FORMATS PASSED THE TEST *****
**************************************/
// WORKING
formatsGmEnabled << "*.avs" //AVS X image
<< "*.x"
// WORKING
<< "*.cals" // Continuous Acquisition and Life-cycle Support Type 1 image
<< "*.cal"
<< "*.dcl"
<< "*.ras"
// WORKING
<< "*.cin" // Kodak Cineon
// WORKING
<< "*.cut" // DR Halo
// WORKING
<< "*.acr" // Digital Imaging and Communications in Medicine (DICOM) image
<< "*.dcm"
<< "*.dicom"
<< "*.dic"
// WORKING
<< "*.dcx" // ZSoft IBM PC multi-page Paintbrush image
// WORKING
<< "*.dib" // Microsoft Windows Device Independent Bitmap
// WORKING
<< "*.dpx" // Digital Moving Picture Exchange
// WORKING
<< "*.epdf" // Encapsulated Portable Document Format
// WORKING (Ghostscript required)
<< "*.epi" // Adobe Encapsulated PostScript Interchange format
<< "*.epsi"
// WORKING (Ghostscript required)
<< "*.eps" // Adobe Encapsulated PostScript
<< "*.epsf"
// WORKING (Ghostscript required)
<< "*.eps2" // Adobe Level II Encapsulated PostScript
// WORKING (Ghostscript required)
<< "*.eps3" // Adobe Level III Encapsulated PostScript
// WORKING (Ghostscript required)
<< "*.ept" // Adobe Encapsulated PostScript Interchange format with TIFF preview
// WORKING
<< "*.fax" // Group 3 FAX
// WORKING
<< "*.fits" // Flexible Image Transport System
<< "*.fts"
<< "*.fit"
// WORKING
<< "*.fpx" // FlashPix Format
// WORKING
<< "*.jng" // JPEG Network Graphics
// WORKING
<< "*.mat" // MATLAB image format
// WORKING
<< "*.miff" // Magick image file format
// WORKING
<< "*.mono" // Bi-level bitmap in least-significant-byte first order
// WORKING
<< "*.mtv" // MTV Raytracing image format
// WORKING
<< "*.otb" // On-the-air Bitmap
// WORKING
<< "*.p7" // Xv's Visual Schnauzer thumbnail format
// WORKING
<< "*.palm" // Palm pixmap
// WORKING
<< "*.pam" // Portable Arbitrary Map format
// WORKING
<< "*.pcd" // Photo CD
<< "*.pcds"
// WORKING
<< "*.pcx" // ZSoft IBM PC Paintbrush file
// WORKING
<< "*.pdb" // Palm Database ImageViewer Format
// WORKING (Ghostscript required)
<< "*.pdf" // Portable Document Format
// WORKING
<< "*.pict" // Apple Macintosh QuickDraw /PICT file
<< "*.pct"
<< "*.pic"
// WORKING
<< "*.pix" // Alias/Wavefront RLE image format
<< "*.pal"
// WORKING
<< "*.pnm" // Portable anymap
// WORKING (Ghostscript required)
<< "*.ps" // Adobe PostScript file
// WORKING (Ghostscript required)
<< "*.ps2" // Adobe Level II PostScript file
// WORKING (Ghostscript required)
<< "*.ps3" // Adobe Level III PostScript file
// WORKING
<< "*.psd" // Adobe Photoshop bitmap file
// WORKING
<< "*.ptif" // Pyramid encoded TIFF
<< "*.ptiff"
// WORKING
<< "*.sfw" // Seattle File Works image
// WORKING
<< "*.sgi" // Irix RGB image
// WORKING
<< "*.sun" // SUN Rasterfile
// WORKING
<< "*.tga" // Truevision Targa image
// WORKING
<< "*.txt" // Text files
// WORKING
<< "*.vicar" // VICAR rasterfile format
// WORKING
<< "*.viff" // Khoros Visualization Image File Format
// WORKING
<< "*.wpg" // Word Perfect Graphics File
// WORKING
<< "*.xwd" // X Windows system window dump
// UNTESTED (no test image available)
<< "*.hp" // HP-GL plotter language
<< "*.hpgl"
<< "*.jbig" // Joint Bi-level Image experts Group file interchange format
<< "*.jbg"
<< "*.pwp" // Seattle File Works multi-image file
<< "*.rast" // Sun Raster Image
<< "*.rla" // Alias/Wavefront image file
<< "*.rle" // Utah Run length encoded image file
<< "*.sct" // Scitex Continuous Tone Picture
<< "*.tim"; // PSX TIM file
#endif
}
// Read formats from file (if available)
void getFormats() {
setDefaultFormats();
QFile file(QDir::homePath() + "/.photoqt/fileformats.disabled");
if(file.exists()) {
if(!file.open(QIODevice::ReadOnly))
std::cerr << "ERROR: Can't open disabled image formats file" << std::endl;
else {
QTextStream in(&file);
QString line = in.readLine();
while (!line.isNull()) {
line = line.trimmed();
if(line.length() != 0 && formatsQtEnabled.contains(line))
formatsQtEnabled.removeAll(line);
if(line.length() != 0 && formatsExtrasEnabled.contains(line))
formatsExtrasEnabled.removeAll(line);
if(line.length() != 0 && formatsGmEnabled.contains(line))
formatsGmEnabled.removeAll(line);
line = in.readLine();
}
}
}
}
// Save all enabled formats to file
void saveFormats(QStringList new_qtformats, QStringList new_gmformats, QStringList new_extrasFormats) {
setDefaultFormats();
if(!readonly) {
QStringList disabled;
for(int i = 0; i < formatsQtEnabled.length(); ++i) {
if(!new_qtformats.contains(formatsQtEnabled.at(i)))
disabled.append(formatsQtEnabled.at(i));
}
for(int i = 0; i < formatsGmEnabled.length(); ++i) {
if(!new_gmformats.contains(formatsGmEnabled.at(i)))
disabled.append(formatsGmEnabled.at(i));
}
for(int i = 0; i < formatsExtrasEnabled.length(); ++i) {
if(!new_extrasFormats.contains(formatsExtrasEnabled.at(i)))
disabled.append(formatsExtrasEnabled.at(i));
}
formatsQtEnabled = new_qtformats;
formatsGmEnabled = new_gmformats;
formatsExtrasEnabled = new_extrasFormats;
QFile file(QDir::homePath() + "/.photoqt/fileformats.disabled");
if(file.exists()) {
if(!file.remove())
std::cerr << "ERROR: Cannot replace disabled image formats file" << std::endl;
}
if(!file.open(QIODevice::WriteOnly))
std::cerr << "ERROR: Cannot write to disabled image formats file" << std::endl;
else {
QTextStream out(&file);
out << disabled.join("\n");
file.close();
}
}
}
void setReadonly(bool ro) {
readonly = ro;
}
};
#endif // FILEFORMATS_H