1 package de.desy.acop.video.displayer;
2
3 import java.util.HashMap;
4 import java.util.Map;
5
6
7
8
9
10
11
12 public enum ImageFormat {
13
14
15
16 IMAGE_FORMAT_GRAY(0, true),
17
18
19
20
21 IMAGE_FORMAT_RGB(1, true),
22
23
24
25
26 IMAGE_FORMAT_RGBA(2, true),
27
28
29
30
31 IMAGE_FORMAT_RGB15(3),
32
33
34
35
36 IMAGE_FORMAT_RGB16(4),
37
38
39
40
41 IMAGE_FORMAT_JPEG(5, true),
42
43
44
45
46 IMAGE_FORMAT_TIFF(6),
47
48
49
50
51 IMAGE_FORMAT_YUV411(7),
52
53
54
55
56 IMAGE_FORMAT_YUV422(8),
57
58
59
60
61 IMAGE_FORMAT_YUV444(9),
62
63
64
65
66 IMAGE_FORMAT_HUFFYUV(10, true),
67
68
69
70
71 IMAGE_FORMAT_BMP(11),
72
73
74
75
76 IMAGE_FORMAT_BAYER(12);
77
78 private final int id;
79 private final boolean isSupported;
80
81 private static Map<Integer, ImageFormat> map = new HashMap<Integer, ImageFormat>(values().length);
82 static {
83 for (ImageFormat e : values())
84 if (map.put(e.id, e) != null)
85 throw new InternalError("duplicate id: " + e.id);
86 }
87
88 private ImageFormat(int id) {
89 this(id, false);
90 }
91
92 private ImageFormat(int id, boolean isSupported) {
93 this.id = id;
94 this.isSupported = isSupported;
95 }
96
97
98
99
100
101
102 public int getId() {
103 return id;
104 }
105
106
107
108
109
110
111 public boolean isSupported() {
112 return isSupported;
113 }
114
115 public boolean equals(int id) {
116 return this.id == id;
117 }
118
119 public static ImageFormat valueOf(int id) throws IllegalArgumentException {
120 ImageFormat e = map.get(id);
121 if (e == null)
122 throw new IllegalArgumentException("non-existing image format id: " + id);
123 return e;
124 }
125
126 }