RGBFormatpublic class RGBFormat extends VideoFormat Describes uncompressed RGB data. The data is in
interleaved form. RGB components can be packed into
a short or an int. If the pixel components are packed, then the
redMask , greenMask and blueMask fields
specify the bit masks, otherwise
they specify the order of arrangement of the components. For example:
- 32-bit packed RGB stored as 32-bit integers would have
the following masks: redMask = 0x00FF0000, greenMask = 0x0000FF00,
blueMask = 0x000000FF.
- 24-bit RGB stored as bytes would have the following masks:
redMask = 1, greenMask = 2, blueMask = 3 and pixelStride = 3.
|
Fields Summary |
---|
protected int | redMaskMask value for the Red component. | protected int | greenMaskMask value for the Green component. | protected int | blueMaskMask value for the Blue component. | protected int | bitsPerPixelThe number of bits required to represent a pixel, including all three
color components. | protected int | pixelStrideIncrement value of the array index from one pixel to the next. | protected int | lineStrideIncrement value of the array index from the first pixel on line n
to the first pixel on line n+1. | protected int | flippedIndicates whether or not the lines in the video frame are flipped vertically
(upside down). | protected int | endianEndian ordering of the data where applicable | public static final int | BIG_ENDIAN | public static final int | LITTLE_ENDIAN | private static String | ENCODING |
Constructors Summary |
---|
public RGBFormat()Constructs a default RGBFormat .
super(ENCODING);
dataType = null;
| public RGBFormat(Dimension size, int maxDataLength, Class dataType, float frameRate, int bitsPerPixel, int red, int green, int blue)Constructs an RGBFormat object with the specified properties.
The pixel stride is
initialized to the default for the specified data type and bits per pixel.
The line stride is initialized using the default pixel stride and specified frame
width.
The image is not flipped and the endian is LITTLE_ENDIAN.
super(ENCODING, size, maxDataLength, dataType, frameRate);
this.bitsPerPixel = bitsPerPixel;
this.redMask = red;
this.greenMask = green;
this.blueMask = blue;
if (bitsPerPixel != NOT_SPECIFIED && dataType != null) {
pixelStride = bitsPerPixel / 8;
if (dataType != byteArray)
pixelStride = 1;
} else {
pixelStride = NOT_SPECIFIED;
}
if (size != null && pixelStride != NOT_SPECIFIED)
lineStride = pixelStride * size.width;
else
lineStride = NOT_SPECIFIED;
flipped = FALSE;
if (bitsPerPixel == 16 && dataType == byteArray)
endian = LITTLE_ENDIAN;
else
endian = NOT_SPECIFIED;
| public RGBFormat(Dimension size, int maxDataLength, Class dataType, float frameRate, int bitsPerPixel, int red, int green, int blue, int pixelStride, int lineStride, int flipped, int endian)Constructs an RGBFormat object with the specified properties.
super(ENCODING, size, maxDataLength, dataType, frameRate);
this.bitsPerPixel = bitsPerPixel;
this.redMask = red;
this.greenMask = green;
this.blueMask = blue;
this.pixelStride = pixelStride;
this.lineStride = lineStride;
this.flipped = flipped;
this.endian = endian;
|
Methods Summary |
---|
public java.lang.Object | clone()Creates a clone of this RGBFormat .
RGBFormat f = new RGBFormat(size,
maxDataLength,
dataType,
frameRate,
bitsPerPixel,
redMask,
greenMask,
blueMask,
pixelStride,
lineStride,
flipped,
endian);
f.copy(this);
return f;
| protected void | copy(javax.media.Format f)Copies the attributes from the specified Format into
this RGBFormat .
super.copy(f);
if (f instanceof RGBFormat) {
RGBFormat other = (RGBFormat) f;
bitsPerPixel = other.bitsPerPixel;
redMask = other.redMask;
greenMask = other.greenMask;
blueMask = other.blueMask;
pixelStride = other.pixelStride;
lineStride = other.lineStride;
flipped = other.flipped;
endian = other.endian;
}
| public boolean | equals(java.lang.Object format)Compares the specified Format with this RGBFormat .
Returns true only if the specified Format
is a RGBFormat object and all of
its attributes are identical to
the attributes in this RGBFormat .
if (format instanceof RGBFormat) {
RGBFormat other = (RGBFormat) format;
return super.equals(format) &&
bitsPerPixel == other.bitsPerPixel &&
redMask == other.redMask &&
greenMask == other.greenMask &&
blueMask == other.blueMask &&
pixelStride == other.pixelStride &&
lineStride == other.lineStride &&
endian == other.endian &&
flipped == other.flipped;
} else
return false;
| public int | getBitsPerPixel()Gets the number of bits required per pixel of data.
return bitsPerPixel;
| public int | getBlueMask()Gets the mask for the blue component.
return blueMask;
| public int | getEndian()Gets the endian ordering of the data for unpacked 16-bit data.
return endian;
| public int | getFlipped()Checks whether or not the video image is vertically flipped.
return flipped;
| public int | getGreenMask()Gets the mask for the green component.
return greenMask;
| public int | getLineStride()Gets the line stride--the number of array elements between adjacent rows of pixels.
return lineStride;
| public int | getPixelStride()Gets the pixel stride--the number of array elements between adjacent pixels.
return pixelStride;
| public int | getRedMask()Gets the mask for the red component.
return redMask;
| public javax.media.Format | intersects(javax.media.Format format)Finds the attributes shared by two matching Format objects.
If the specified Format does not match this one, the result
is undefined.
Format fmt;
if ((fmt = super.intersects(format)) == null)
return null;
if (!(format instanceof RGBFormat))
return fmt;
RGBFormat other = (RGBFormat)format;
RGBFormat res = (RGBFormat)fmt;
res.bitsPerPixel = (bitsPerPixel != NOT_SPECIFIED ?
bitsPerPixel : other.bitsPerPixel);
res.pixelStride = (pixelStride != NOT_SPECIFIED ?
pixelStride : other.pixelStride);
res.lineStride = (lineStride != NOT_SPECIFIED ?
lineStride : other.lineStride);
res.redMask = (redMask != NOT_SPECIFIED ?
redMask : other.redMask);
res.greenMask = (greenMask != NOT_SPECIFIED ?
greenMask : other.greenMask);
res.blueMask = (blueMask != NOT_SPECIFIED ?
blueMask : other.blueMask);
res.flipped = (flipped != NOT_SPECIFIED ?
flipped : other.flipped);
res.endian = (endian != NOT_SPECIFIED ?
endian : other.endian);
return res;
| public boolean | matches(javax.media.Format format)Checks whether or not the specified Format matches
this RGBFormat .
Matches only compares the attributes that are defined in the specified
Format ,
unspecified attributes are ignored.
The two Format objects do not have to be of the same class
to match. For example, if "A" are "B" are being compared, a
match is possible if "A" is derived from "B"
or "B" is derived from "A". (The compared attributes must still match,
or matches fails.)
if (!super.matches(format))
return false;
if (!(format instanceof RGBFormat))
return true;
RGBFormat other = (RGBFormat) format;
boolean returnVal =
(bitsPerPixel == NOT_SPECIFIED || other.bitsPerPixel == NOT_SPECIFIED ||
bitsPerPixel == other.bitsPerPixel) &&
(redMask == NOT_SPECIFIED || other.redMask == NOT_SPECIFIED ||
redMask == other.redMask) &&
(greenMask == NOT_SPECIFIED || other.greenMask == NOT_SPECIFIED ||
greenMask == other.greenMask) &&
(blueMask == NOT_SPECIFIED || other.blueMask == NOT_SPECIFIED ||
blueMask == other.blueMask) &&
(pixelStride == NOT_SPECIFIED || other.pixelStride == NOT_SPECIFIED ||
pixelStride == other.pixelStride) &&
(endian == NOT_SPECIFIED || other.endian == NOT_SPECIFIED ||
endian == other.endian) &&
(flipped == NOT_SPECIFIED || other.flipped == NOT_SPECIFIED ||
flipped == other.flipped);
return returnVal;
| public javax.media.Format | relax()Generate a format that's less restrictive than this format but
contains the basic attributes that will make this resulting format
useful for format matching.
RGBFormat fmt;
if ((fmt = (RGBFormat)super.relax()) == null)
return null;
fmt.lineStride = NOT_SPECIFIED;
fmt.pixelStride = NOT_SPECIFIED;
return fmt;
| public java.lang.String | toString()Gets a String representation of the attributes of this
RGBFormat .
For example: "RGB, 352x240, ...".
String s = getEncoding().toUpperCase();
if (size != null)
s += ", " + size.width + "x" + size.height;
if (frameRate != NOT_SPECIFIED)
s += ", FrameRate=" + ((int)(frameRate * 10) / 10f);
if (maxDataLength != NOT_SPECIFIED)
s += ", Length=" + maxDataLength;
s += ", " + bitsPerPixel + "-bit";
s += ", Masks=" + redMask + ":" + greenMask + ":" + blueMask;
if (pixelStride != 1)
s += ", PixelStride=" + pixelStride;
s += ", LineStride=" + lineStride;
if (flipped != NOT_SPECIFIED)
s += (flipped == Format.TRUE? ", Flipped" : "");
if (dataType == byteArray && bitsPerPixel == 16 && endian != NOT_SPECIFIED)
s += (endian == BIG_ENDIAN? ", BigEndian" : ", LittleEndian");
if (dataType != null && dataType != Format.byteArray)
s += ", " + dataType;
return s;
|
|