1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.imaging.roundtrip;
19
20 import org.apache.commons.imaging.ImageFormat;
21 import org.apache.commons.imaging.ImageFormats;
22
23 final class FormatInfo {
24
25 static final int COLOR_FULL_RGB = 0;
26 static final int COLOR_LIMITED_INDEX = 1;
27 static final int COLOR_GRAYSCALE = 2;
28 static final int COLOR_BITMAP = 3;
29
30 static final FormatInfo[] PRESERVING_RESOLUTION_FORMATS = { new FormatInfo(ImageFormats.PNG, true, true, COLOR_FULL_RGB, true, true),
31 new FormatInfo(ImageFormats.ICO, true, true, COLOR_FULL_RGB, true, true),
32 new FormatInfo(ImageFormats.TIFF, true, true, COLOR_FULL_RGB, true, true),
33 new FormatInfo(ImageFormats.BMP, true, true, COLOR_FULL_RGB, true, true),
34 new FormatInfo(ImageFormats.PCX, true, true, COLOR_FULL_RGB, true, true),
35 new FormatInfo(ImageFormats.DCX, true, true, COLOR_FULL_RGB, true, true),
36 };
37
38 static final FormatInfo[] READ_WRITE_FORMATS = { new FormatInfo(ImageFormats.PNG, true, true, COLOR_FULL_RGB, true, true),
39 new FormatInfo(ImageFormats.GIF, true, true, COLOR_LIMITED_INDEX, true, false),
40 new FormatInfo(ImageFormats.ICO, true, true, COLOR_FULL_RGB, true, true),
41 new FormatInfo(ImageFormats.TIFF, true, true, COLOR_FULL_RGB, true, true),
42 new FormatInfo(ImageFormats.BMP, true, true, COLOR_FULL_RGB, true, true),
43 new FormatInfo(ImageFormats.PBM, true, true, COLOR_BITMAP, true, false),
44 new FormatInfo(ImageFormats.PGM, true, true, COLOR_GRAYSCALE, true, false),
45 new FormatInfo(ImageFormats.PPM, true, true, COLOR_FULL_RGB, true, false),
46 new FormatInfo(ImageFormats.PAM, true, true, COLOR_FULL_RGB, true, false),
47 new FormatInfo(ImageFormats.WBMP, true, true, COLOR_BITMAP, true, false),
48 new FormatInfo(ImageFormats.PCX, true, true, COLOR_FULL_RGB, true, true),
49 new FormatInfo(ImageFormats.DCX, true, true, COLOR_FULL_RGB, true, true),
50 new FormatInfo(ImageFormats.XBM, true, true, COLOR_BITMAP, false, false),
51 new FormatInfo(ImageFormats.XPM, true, true, COLOR_FULL_RGB, false, false),
52 };
53
54 static final FormatInfo[] ALL_FORMATS = {
55 new FormatInfo(ImageFormats.PNG, true, true, COLOR_FULL_RGB, true, true),
56 new FormatInfo(ImageFormats.GIF, true, true, COLOR_LIMITED_INDEX, true, false),
57 new FormatInfo(ImageFormats.ICO, true, true, COLOR_FULL_RGB, true, true),
58 new FormatInfo(ImageFormats.TIFF, true, true, COLOR_FULL_RGB, true, true),
59 new FormatInfo(ImageFormats.JPEG, true, false, COLOR_FULL_RGB, true, true),
60 new FormatInfo(ImageFormats.BMP, true, true, COLOR_FULL_RGB, true, true),
61 new FormatInfo(ImageFormats.PSD, true, false, COLOR_FULL_RGB, true, true),
62 new FormatInfo(ImageFormats.PBM, true, true, COLOR_BITMAP, true, false),
63 new FormatInfo(ImageFormats.PGM, true, true, COLOR_GRAYSCALE, true, false),
64 new FormatInfo(ImageFormats.PPM, true, true, COLOR_FULL_RGB, true, false),
65 new FormatInfo(ImageFormats.PAM, true, true, COLOR_FULL_RGB, true, false),
66 new FormatInfo(ImageFormats.PNM, true, true, COLOR_FULL_RGB, true, false),
67 new FormatInfo(ImageFormats.TGA, false, false, COLOR_FULL_RGB, true, true),
68 new FormatInfo(ImageFormats.WBMP, true, true, COLOR_BITMAP, true, false),
69 new FormatInfo(ImageFormats.PCX, true, true, COLOR_FULL_RGB, true, true),
70 new FormatInfo(ImageFormats.DCX, true, true, COLOR_FULL_RGB, true, true),
71 new FormatInfo(ImageFormats.XBM, true, true, COLOR_BITMAP, false, false),
72 new FormatInfo(ImageFormats.XPM, true, true, COLOR_FULL_RGB, false, false),
73 };
74
75 final ImageFormat format;
76 final boolean canRead;
77 final boolean canWrite;
78 final int colorSupport;
79 final boolean identicalSecondWrite;
80 final boolean preservesResolution;
81
82 FormatInfo(final ImageFormat format, final boolean canRead, final boolean canWrite, final int colorSupport, final boolean identicalSecondWrite,
83 final boolean preservesResolution) {
84 this.canRead = canRead;
85 this.canWrite = canWrite;
86 this.colorSupport = colorSupport;
87 this.format = format;
88 this.identicalSecondWrite = identicalSecondWrite;
89 this.preservesResolution = preservesResolution;
90 }
91
92 @Override
93 public String toString() {
94 return "FormatInfo{" + "format=" + format + ", canRead=" + canRead + ", canWrite=" + canWrite + ", colorSupport=" + colorSupport
95 + ", identicalSecondWrite=" + identicalSecondWrite + ", preservesResolution=" + preservesResolution + '}';
96 }
97 }