Skip to content

Commit 156480e

Browse files
committed
#15 Add new abstract classes describing an image
1 parent 6a4dd77 commit 156480e

3 files changed

Lines changed: 338 additions & 0 deletions

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/**
2+
* Copyright (C) 2010-18 diirt developers. See COPYRIGHT.TXT
3+
* All rights reserved. Use is subject to license terms. See LICENSE.TXT
4+
*/
5+
package org.epics.vtype;
6+
7+
import org.epics.util.array.ListNumber;
8+
9+
/**
10+
* VImage represents an image.
11+
*
12+
* @author carcassi, shroff
13+
*/
14+
public abstract class VImage extends VType implements AlarmProvider, TimeProvider {
15+
16+
/**
17+
* Height of the image in pixels.
18+
*
19+
* @return image height
20+
*/
21+
public abstract int getHeight();
22+
23+
/**
24+
* Width of the image in pixels.
25+
*
26+
* @return image width
27+
*/
28+
public abstract int getWidth();
29+
30+
/**
31+
* Image data;
32+
*
33+
* @return ListNumber image data
34+
*/
35+
public abstract ListNumber getData();
36+
37+
/**
38+
* Describes the type in which the data is stored
39+
* {@link VImageDataType}
40+
*
41+
* @return image data type
42+
*/
43+
public abstract VImageDataType getDataType();
44+
45+
/**
46+
* Returns the image type, The image type describes the mechanism in which
47+
* the data is encoded and how it can be converted to something that can be
48+
* rendered.
49+
*
50+
* @return the image type {@link VImageType}
51+
*/
52+
public abstract VImageType getVImageType();
53+
54+
/**
55+
* Creates a new VImage.
56+
*
57+
* @param value the value
58+
* @param alarm the alarm
59+
* @param time the time
60+
* @param display the display
61+
* @return the new value
62+
*/
63+
public static VImage of(int height, int width, final ListNumber data, VImageDataType imageDataType, Alarm alarm, Time time) {
64+
return new IVImage(height, width, data, imageDataType, VImageType.TYPE_3BYTE_BGR, alarm, time);
65+
}
66+
}
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
/**
2+
* Copyright (C) 2010-18 diirt developers. See COPYRIGHT.TXT
3+
* All rights reserved. Use is subject to license terms. See LICENSE.TXT
4+
*/
5+
package org.epics.vtype;
6+
/**
7+
*
8+
* Data type description for {@link VImage} data.
9+
*
10+
* based on the the VImageDataType from org.epics.pvdata.pv
11+
* @author mrk
12+
*
13+
*/
14+
public enum VImageDataType {
15+
/**
16+
* Value has type <i>boolean</i>.
17+
*/
18+
pvBoolean,
19+
/**
20+
* Value has type <i>byte</i>.
21+
*/
22+
pvByte,
23+
/**
24+
* Value has type <i>short</i>.
25+
*/
26+
pvShort,
27+
/**
28+
* Value has type <i>int</i>.
29+
*/
30+
pvInt,
31+
/**
32+
* Value has type <i>long</i>.
33+
*/
34+
pvLong,
35+
/**
36+
* Value has type <i>ubyte</i>.
37+
*/
38+
pvUByte,
39+
/**
40+
* Value has type <i>ushort</i>.
41+
*/
42+
pvUShort,
43+
/**
44+
* Value has type <i>uint</i>.
45+
*/
46+
pvUInt,
47+
/**
48+
* Value has type <i>ulong</i>.
49+
*/
50+
pvULong,
51+
/**
52+
* value has type <i>float</i>.
53+
*/
54+
pvFloat,
55+
/**
56+
* Value has type <i>double</i>.
57+
*/
58+
pvDouble,
59+
/**
60+
* Value has type <i>string</i>.
61+
*/
62+
pvString;
63+
64+
/**
65+
* Is this an integer (signed or unsigned). true if byte, short, int, long, ubyte, ushort, uint, or ulong.
66+
* @return true if it is an integer type
67+
*/
68+
public boolean isInteger() {
69+
if( (ordinal() >= VImageDataType.pvByte.ordinal()) && (ordinal() <= VImageDataType.pvULong.ordinal()) ) {
70+
return true;
71+
}
72+
return false;
73+
}
74+
75+
/**
76+
* Is this an unsigned integer. true if ubyte, ushort, uint, or ulong.
77+
*
78+
* @return true if it is an unsigned integer type
79+
*/
80+
public boolean isUInteger() {
81+
if( (ordinal() >= VImageDataType.pvUByte.ordinal()) && (ordinal() <= VImageDataType.pvULong.ordinal()) ) {
82+
return true;
83+
}
84+
return false;
85+
}
86+
87+
/**
88+
* Is this a Java numeric type?
89+
*
90+
* @return true if the type is a Java numeric type.
91+
* The numeric types are byte, short, int, long, float, and double.
92+
*/
93+
public boolean isNumeric() {
94+
if( (ordinal() >= VImageDataType.pvByte.ordinal()) && (ordinal() <= VImageDataType.pvDouble.ordinal()) ) {
95+
return true;
96+
}
97+
return false;
98+
}
99+
100+
/**
101+
* Is this a Java primitive type?
102+
*
103+
* @return true if the type is a Java primitive type.
104+
* The numeric types and boolean are primitive types.
105+
*/
106+
public boolean isPrimitive() {
107+
if(isNumeric()) return true;
108+
if(ordinal() == VImageDataType.pvBoolean.ordinal()) return true;
109+
return false;
110+
}
111+
112+
/**
113+
* Get the VImageDataType for a string defining the type.
114+
*
115+
* @param type a character string defining the type
116+
* @return the VImageDataType or null if an illegal type
117+
*/
118+
public static VImageDataType getVImageDataType(String type) {
119+
if(type.equals("boolean")) return VImageDataType.pvBoolean;
120+
if(type.equals("byte")) return VImageDataType.pvByte;
121+
if(type.equals("short")) return VImageDataType.pvShort;
122+
if(type.equals("int")) return VImageDataType.pvInt;
123+
if(type.equals("long")) return VImageDataType.pvLong;
124+
if(type.equals("ubyte")) return VImageDataType.pvUByte;
125+
if(type.equals("ushort")) return VImageDataType.pvUShort;
126+
if(type.equals("uint")) return VImageDataType.pvUInt;
127+
if(type.equals("ulong")) return VImageDataType.pvULong;
128+
if(type.equals("float")) return VImageDataType.pvFloat;
129+
if(type.equals("double")) return VImageDataType.pvDouble;
130+
if(type.equals("string")) return VImageDataType.pvString;
131+
return null;
132+
}
133+
public String toString() {
134+
switch(this) {
135+
case pvBoolean: return "boolean";
136+
case pvByte: return "byte";
137+
case pvShort: return "short";
138+
case pvInt: return "int";
139+
case pvLong: return "long";
140+
case pvUByte: return "ubyte";
141+
case pvUShort: return "ushort";
142+
case pvUInt: return "uint";
143+
case pvULong: return "ulong";
144+
case pvFloat: return "float";
145+
case pvDouble: return "double";
146+
case pvString: return "string";
147+
}
148+
throw new IllegalArgumentException("Unknown VImageDataType");
149+
}
150+
}
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/**
2+
* Copyright (C) 2010-18 diirt developers. See COPYRIGHT.TXT
3+
* All rights reserved. Use is subject to license terms. See LICENSE.TXT
4+
*/
5+
6+
package org.epics.vtype;
7+
8+
/**
9+
* Description of the the Image Type represented by the {@link VImage}
10+
*
11+
* @author Kunal Shroff
12+
*
13+
*/
14+
public enum VImageType {
15+
/**
16+
* Image type constants
17+
*/
18+
TYPE_CUSTOM,
19+
/**
20+
* Monochromatic image
21+
*/
22+
TYPE_MONO,
23+
/**
24+
* Bayer pattern image, 1 value per pixel but with color filter on
25+
* detector
26+
*/
27+
TYPE_BAYER,
28+
/**
29+
* RGB image with pixel color interleave, data array is [3, NX, NY]
30+
*/
31+
TYPE_RGB1,
32+
/**
33+
* RGB image with row color interleave, data array is [NX, 3, NY]
34+
*/
35+
TYPE_RGB2,
36+
/**
37+
* RGB image with plane color interleave, data array is [NX, NY, 3]
38+
*/
39+
TYPE_RGB3,
40+
/**
41+
* YUV image, 3 bytes encodes 1 RGB pixel
42+
*/
43+
TYPE_YUV444,
44+
/**
45+
* YUV image, 4 bytes encodes 2 RGB pixel
46+
*/
47+
TYPE_YUV422,
48+
/**
49+
* YUV image, 6 bytes encodes 4 RGB pixels
50+
*/
51+
TYPE_YUV411,
52+
/**
53+
* An image with 8-bit RGB color components, corresponding to a
54+
* Windows-style BGR color model with the colors Blue, Green, and Red
55+
* stored in 3 bytes.
56+
*/
57+
TYPE_3BYTE_BGR,
58+
/**
59+
* Represents an image with 8-bit RGBA color components with the colors
60+
* Blue, Green, and Red stored in 3 bytes and 1 byte of alpha.
61+
*/
62+
TYPE_4BYTE_ABGR,
63+
/**
64+
* Represents an image with 8-bit RGBA color components with the colors
65+
* Blue, Green, and Red stored in 3 bytes and 1 byte of alpha.
66+
*/
67+
TYPE_4BYTE_ABGR_PRE,
68+
/**
69+
* Represents an opaque byte-packed 1, 2, or 4 bit image.
70+
*/
71+
TYPE_BYTE_BINARY,
72+
/**
73+
* Represents a unsigned byte grayscale image, non-indexed.
74+
*/
75+
TYPE_BYTE_GRAY,
76+
/**
77+
* Represents an indexed byte image.
78+
*/
79+
TYPE_BYTE_INDEXED,
80+
/**
81+
* Represents an image with 8-bit RGBA color components packed into
82+
* integer pixels.
83+
*
84+
*/
85+
TYPE_INT_ARGB,
86+
/**
87+
* Represents an image with 8-bit RGBA color components packed into
88+
* integer pixels.
89+
*
90+
*/
91+
TYPE_INT_ARGB_PRE,
92+
/**
93+
* Represents an image with 8-bit RGB color components, corresponding to
94+
* a Windows- or Solaris- style BGR color model, with the colors Blue,
95+
* Green, and Red packed into integer pixels.
96+
*
97+
*/
98+
TYPE_INT_BGR,
99+
/**
100+
* Represents an image with 8-bit RGB color components packed into
101+
* integer pixels.
102+
*
103+
*/
104+
TYPE_INT_RGB,
105+
/**
106+
* Represents an image with 5-5-5 RGB color components (5-bits red,
107+
* 5-bits green, 5-bits blue) with no alpha.
108+
*
109+
*/
110+
TYPE_USHORT_555_RGB,
111+
/**
112+
* Represents an image with 5-6-5 RGB color components (5-bits red,
113+
* 6-bits green, 5-bits blue) with no alpha.
114+
*
115+
*/
116+
TYPE_USHORT_565_RGB,
117+
/**
118+
* Represents an unsigned short grayscale image, non-indexed).
119+
*
120+
*/
121+
TYPE_USHORT_GRAY
122+
}

0 commit comments

Comments
 (0)