FileDocCategorySizeDatePackage
BogusColorSpace.javaAPI DocJava SE 5 API3473Fri Aug 26 14:54:42 BST 2005com.sun.imageio.plugins.common

BogusColorSpace

public class BogusColorSpace extends ColorSpace
A dummy ColorSpace to enable ColorModel for image data which do not have an innate color representation.

Fields Summary
Constructors Summary
public BogusColorSpace(int numComponents)
Constructs a bogus ColorSpace.

param
numComponents The number of components in the ColorSpace.
exception
IllegalArgumentException if numComponents is less than 1.

        super(getType(numComponents), numComponents);
    
Methods Summary
public float[]fromCIEXYZ(float[] xyzvalue)

        if(xyzvalue.length < 3) {
            throw new ArrayIndexOutOfBoundsException
                ("xyzvalue.length < 3");
        }

        float[] colorvalue = new float[getNumComponents()];

        System.arraycopy(xyzvalue, 0, colorvalue, 0,
                         Math.min(3, colorvalue.length));

        return xyzvalue;
    
public float[]fromRGB(float[] rgbvalue)

        if(rgbvalue.length < 3) {
            throw new ArrayIndexOutOfBoundsException
                ("rgbvalue.length < 3");
        }

        float[] colorvalue = new float[getNumComponents()];

        System.arraycopy(rgbvalue, 0, colorvalue, 0,
                         Math.min(3, colorvalue.length));

        return rgbvalue;
    
private static intgetType(int numComponents)
Return the type given the number of components.

param
numComponents The number of components in the ColorSpace.
exception
IllegalArgumentException if numComponents is less than 1.

        if(numComponents < 1) {
            throw new IllegalArgumentException("numComponents < 1!");
        }

        int type;
        switch(numComponents) {
        case 1:
            type = ColorSpace.TYPE_GRAY;
            break;
        default:
            // Based on the constant definitions TYPE_2CLR=12 through
            // TYPE_FCLR=25. This will return unknown types for
            // numComponents > 15.
            type = numComponents + 10;
        }

        return type;
    
public float[]toCIEXYZ(float[] colorvalue)

        if(colorvalue.length < getNumComponents()) {
            throw new ArrayIndexOutOfBoundsException
                ("colorvalue.length < getNumComponents()");
        }

        float[] xyzvalue = new float[3];

        System.arraycopy(colorvalue, 0, xyzvalue, 0,
                         Math.min(3, getNumComponents()));

        return colorvalue;
    
public float[]toRGB(float[] colorvalue)

        if(colorvalue.length < getNumComponents()) {
            throw new ArrayIndexOutOfBoundsException
                ("colorvalue.length < getNumComponents()");
        }

        float[] rgbvalue = new float[3];

        System.arraycopy(colorvalue, 0, rgbvalue, 0,
                         Math.min(3, getNumComponents()));

        return colorvalue;