View Javadoc

1   package de.desy.acop.video.displayer;
2   
3   import java.util.HashMap;
4   import java.util.Map;
5   
6   /**
7    * Image format enumeration
8    * 
9    * @author mdavid
10   * 
11   */
12  public enum ImageFormat {
13  	/**
14  	 * Grayscale format
15  	 */
16  	IMAGE_FORMAT_GRAY(0, true),
17  
18  	/**
19  	 * RGB (24bpp r-g-b) format
20  	 */
21  	IMAGE_FORMAT_RGB(1, true),
22  
23  	/**
24  	 * RGB (32bpp a-r-g-b) format
25  	 */
26  	IMAGE_FORMAT_RGBA(2, true),
27  
28  	/**
29  	 * RGB (16bpp 0-5r-5g-5b) format
30  	 */
31  	IMAGE_FORMAT_RGB15(3),
32  
33  	/**
34  	 * RGB (16bpp 5r-6g-5b)) format
35  	 */
36  	IMAGE_FORMAT_RGB16(4),
37  
38  	/**
39  	 * JPEG file
40  	 */
41  	IMAGE_FORMAT_JPEG(5, true),
42  
43  	/**
44  	 * TIFF file
45  	 */
46  	IMAGE_FORMAT_TIFF(6),
47  
48  	/**
49  	 * YUV411 format
50  	 */
51  	IMAGE_FORMAT_YUV411(7),
52  
53  	/**
54  	 * YUV422 format
55  	 */
56  	IMAGE_FORMAT_YUV422(8),
57  
58  	/**
59  	 * YUV444 format
60  	 */
61  	IMAGE_FORMAT_YUV444(9),
62  
63  	/**
64  	 * HuffYUV (compressed grayscale)
65  	 */
66  	IMAGE_FORMAT_HUFFYUV(10, true),
67  
68  	/**
69  	 * Windows BMP file
70  	 */
71  	IMAGE_FORMAT_BMP(11),
72  
73  	/**
74  	 * Bayer pattern
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  	 * Returns integer representation of the TINE image format
99  	 * 
100 	 * @return integer representation of the TINE image format
101 	 */
102 	public int getId() {
103 		return id;
104 	}
105 
106 	/**
107 	 * Returns true if format is supported.
108 	 * 
109 	 * @return true if TINE image format is supported, otherwise false
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 }