FileDocCategorySizeDatePackage
IndexedColorFormat.javaAPI DocJMF 2.1.1e7919Mon May 12 12:20:34 BST 2003javax.media.format

IndexedColorFormat

public class IndexedColorFormat extends VideoFormat
Describes indexed color video data.
since
JMF 2.0

Fields Summary
protected int
lineStride
Increment value of the array index from the first pixel on line n to the first pixel on line n+1.
protected byte[]
redValues
protected byte[]
greenValues
protected byte[]
blueValues
protected int
mapSize
private static String
ENCODING
Constructors Summary
public IndexedColorFormat(Dimension size, int maxDataLength, Class dataType, float frameRate, int lineStride, int mapSize, byte[] red, byte[] green, byte[] blue)
Constructs an IndexedColorFormat object with the specified parameters.

param
size A Dimension that specifies the frame size.
param
maxDataLength The maximum size of a data chunk.
param
dataType The type of data. For example, byte array.
param
frameRate The frame rate.
param
lineStride The number elements between adjacent rows of pixels.
param
mapSize The number of bits required per pixel.
param
red The mask for the red component.
param
green The mask for the green component.
param
blue The mask for the blue component.


                                                                                                    
          
			       
			       
			       
			               
	super(ENCODING, size, maxDataLength, dataType, frameRate);
	this.lineStride = lineStride;
	this.redValues = red;
	this.greenValues = green;
	this.blueValues = blue;
	this.mapSize = mapSize;
    
Methods Summary
public java.lang.Objectclone()
Creates a clone of this IndexedColorFormat by copying each format attribute to the clone.

return
A clone of this IndexedColorFormat.

	IndexedColorFormat f = new IndexedColorFormat(size,
						      maxDataLength,
						      dataType,
						      frameRate,
						      lineStride,
						      mapSize,
						      redValues,
						      greenValues,
						      blueValues);
	f.copy(this);
	return f;
    
protected voidcopy(javax.media.Format f)
Copies the attributes from the specified Format into this H261Format.

param
f The Format to copy the attributes from.

	super.copy(f);
	if (f instanceof IndexedColorFormat) {
	    IndexedColorFormat other = (IndexedColorFormat) f;
	    mapSize = other.mapSize;
	    redValues = other.redValues;
	    greenValues = other.greenValues;
	    blueValues = other.blueValues;
	    lineStride = other.lineStride;
	}
    
public booleanequals(java.lang.Object format)
Compares the specified Format with this H261Format. Returns true only if the specified Format is a H261Format object and all of its attributes are identical to the attributes in this H261Format.

param
format The Format to compare.
return
true if the specified Format is the same as this one.

	if (format instanceof IndexedColorFormat) {
	    IndexedColorFormat other = (IndexedColorFormat) format;
	    
	    return super.equals(format) &&
		mapSize == other.mapSize &&
		redValues == other.redValues &&
		greenValues == other.greenValues &&
		blueValues == other.blueValues &&
		lineStride == other.lineStride;
	} else
	    return false;
    
public byte[]getBlueValues()
Gets the mask for the blue component.

return
A byte array containing the mask for the blue component.

	return blueValues;
    
public byte[]getGreenValues()
Gets the mask for the green component.

return
A byte array containing the mask for the green component.

	return greenValues;
    
public intgetLineStride()
Gets the line stride--the number of array elements between adjacent rows of pixels.

return
An integer representing the line stride.

	return lineStride;
    
public intgetMapSize()
Gets the number of bits required per pixel.

return
An integer representing the number of bits per pixel.

	return mapSize;
    
public byte[]getRedValues()
Gets the mask for the red component.

return
A byte array containing the mask for the red component.

	return redValues;
    
public javax.media.Formatintersects(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.

param
The matching Format to intersect with this H261Format.
return
A Format object with its attributes set to those attributes common to both Format objects.
see
#matches

	Format fmt;
	if ((fmt = super.intersects(format)) == null)
	    return null;
	if (!(format instanceof IndexedColorFormat))
	    return fmt;
	IndexedColorFormat other = (IndexedColorFormat)format;
	IndexedColorFormat res = (IndexedColorFormat)fmt;
	res.mapSize = (mapSize != NOT_SPECIFIED ?
		       mapSize : other.mapSize);
	res.redValues = (redValues != null ?
			 redValues : other.redValues);
	res.greenValues = (greenValues != null ?
			 greenValues : other.greenValues);
	res.blueValues = (blueValues != null ?
			 blueValues : other.blueValues);

	res.lineStride = (lineStride != NOT_SPECIFIED ?
			  lineStride : other.lineStride);
	
	return res;
    
public booleanmatches(javax.media.Format format)
Checks whether or not the specified Format matches this H261Format. 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.)

param
format The Format to compare with this one.
return
true if the specified Format matches this one, false if it does not.

	if (!super.matches(format))
	    return false;
	if (!(format instanceof IndexedColorFormat))
	    return true;

	IndexedColorFormat other = (IndexedColorFormat) format;
	
	return 
	    (mapSize == NOT_SPECIFIED || other.mapSize == NOT_SPECIFIED ||
	     mapSize == other.mapSize) &&
	    
	    (redValues == null || other.redValues == null ||
	     redValues.equals(other.redValues)) &&
	    (greenValues == null || other.greenValues == null ||
	     greenValues.equals(other.greenValues)) &&
	    (blueValues == null || other.blueValues == null ||
	     blueValues.equals(other.blueValues)) &&
	    
	    (lineStride == NOT_SPECIFIED || other.lineStride == NOT_SPECIFIED ||
	     lineStride == other.lineStride) ;
    
public javax.media.Formatrelax()
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.

return
A Format that's less restrictive than the this format.

	IndexedColorFormat fmt;
	if ((fmt = (IndexedColorFormat)super.relax()) == null)
	    return null;

	fmt.lineStride = NOT_SPECIFIED;

	return fmt;