|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.instantreality.InstantIO.Image
public class Image
Helper class for exchanging images.
Image is a basic helper class for exchanging image data between different software components. It does not contain any means for working with images, only methods for setting and getting the raw data values. It is not meant to be used directly by software components for image representation. Instead, software components should use their own, appropriate classes for handling images. Only when sending images to an OutSlot, or when receiving images from an InSlot, the internal representation of images should be converted to Image's. This ensures the interoperability between different software components that use different internal representations for images.
The following example demonstrates how to create an RGB Image of 4x3 pixels and send it to an OutSlot:
OutSlot outSlot = ...; Image image = new Image(); image.setParameters(4, 3, Image.FMT_RGB24); byte[] buffer = image.getBuffer(); buffer[0] = ...; // Red color component of upper left pixel buffer[1] = ...; // Green color component of upper left pixel buffer[2] = ...; // Blue color component of upper left pixel ... buffer[33] = ...; // Red color component of lower right pixel buffer[34] = ...; // Green color component of lower right pixel buffer[35] = ...; // Blue color component of lower right pixel outslot.push(image);
Receiving images from an InSlot works like this:
InSlot inSlot = ...; Image image = (Image) inSlot.pop(); int width = image.getWidth(); int height = image.getHeight(); int format = image.getFormat(); System.out.println("Image parameters: " + width + "x" + height + " " + Image.format2string(format)); byte[] buffer = image.getBuffer(); if (format == Image.FMT_RGB24) { int i = 0; for (int x = 0; x < width; ++x) for (int y = 0; y < height; ++y) { byte r = buffer[i++]; byte g = buffer[i++]; byte b = buffer[i++]; ... } } else { ... }
Field Summary | |
---|---|
static int |
FMT_BGR232
|
static int |
FMT_BGR24
|
static int |
FMT_BGR32
|
static int |
FMT_BGR555
|
static int |
FMT_BGR565
|
static int |
FMT_I420
|
static int |
FMT_IYU2
|
static int |
FMT_NONE
Invalid/unspecified image format. |
static int |
FMT_RGB24
|
static int |
FMT_RGB32
|
static int |
FMT_Y1600
|
static int |
FMT_Y411
|
static int |
FMT_Y41P
|
static int |
FMT_Y422
|
static int |
FMT_Y444
|
static int |
FMT_Y800
|
static int |
FMT_YUV411P
|
static int |
FMT_YUV422P
|
static int |
FMT_YUV9
|
static int |
FMT_YUY2
|
static int |
FMT_YV12
|
static int |
FMT_YVU9
|
Constructor Summary | |
---|---|
Image()
Creates a new Image object. |
Method Summary | |
---|---|
boolean |
equals(java.lang.Object obj)
Compares the image to another object. |
static java.lang.String |
format2String(int format)
Converts a Format enumeration value to a human-readable string. |
byte[] |
getBuffer()
Returns a pointer to the buffer that holds the image data. |
int |
getFormat()
Returns the format of the image data. |
int |
getHeight()
Returns the height of the image data in pixels. |
int |
getSize()
Returns the size of the data in the buffer in bytes. |
int |
getWidth()
Returns the width of the image data in pixels. |
void |
setParameters(int width,
int height,
int format)
This method sets the parameters of the image. |
static int |
string2Format(java.lang.String str)
Converts a human-readable string to a Format enumeration value. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int FMT_NONE
public static final int FMT_BGR232
public static final int FMT_BGR555
public static final int FMT_BGR565
public static final int FMT_BGR24
public static final int FMT_RGB24
public static final int FMT_BGR32
public static final int FMT_RGB32
public static final int FMT_Y444
public static final int FMT_IYU2
public static final int FMT_I420
public static final int FMT_YVU9
public static final int FMT_YUV9
public static final int FMT_Y800
public static final int FMT_Y1600
public static final int FMT_Y422
public static final int FMT_Y411
public static final int FMT_Y41P
public static final int FMT_YV12
public static final int FMT_YUY2
public static final int FMT_YUV422P
public static final int FMT_YUV411P
Constructor Detail |
---|
public Image()
The following example demonstrates how to create an RGB Image of 4x3 pixels:
Image image = new Image(); image.setParameters(4, 3, Image.string2Fromat("RGB24"));
Method Detail |
---|
public final void setParameters(int width, int height, int format)
The following example demonstrates how to create an RGB Image of 4x3 pixels:
Image image = new Image(); image.setParameters(4, 3, Image.string2Fromat("RGB24"));
width
- The width of the image in pixelsheight
- The height of the image in pixelsformat
- The format of the image datapublic final int getWidth()
The following example prints the width of an Image to the console:
Image image = ...; System.out.println("width = " + image.getWidth());
public final int getHeight()
The following example prints the height of an Image to the console:
Image image = ...; System.out.println("height = " + image.getHeight());
public final int getFormat()
The following example prints the format of an Image to the console:
Image image = ...; System.out.println("format = " + Image.format2string(image.getFormat()));
public final byte[] getBuffer()
setParameters
method before calling
this method.
setParameters(int, int, int)
public final int getSize()
setParameters
method before calling
this method. Keep in mind that the size returned by this method
may differ from the size of the buffer - the buffer can be larger
than the actual image data.
setParameters(int, int, int)
public final boolean equals(java.lang.Object obj)
The following example compares two images and prints the result to the console:
Image image1 = ...; Image image2 = ...; System.out.println("Images are the same: " + image1.equals(image2));
equals
in class java.lang.Object
obj
- the object to compare the image to
public static final java.lang.String format2String(int format)
The following example prints the format of an Image to the console:
Image image = ...; System.out.println("format = " + Image.format2string(image.getFormat()));
format
- The Format enumeration value
public static final int string2Format(java.lang.String str)
The following example demonstrates how to create an RGB Image of 4x3 pixels:
Image image = new Image(); image.setParameters(4, 3, Image.string2Fromat("RGB24"));
str
- The human-readable string
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |