Package java.awt.color

Examples of java.awt.color.ColorSpace


     * @param color The color to set.
     * @throws IOException If an IO error occurs while writing to the stream.
     */
    public void setStrokingColor( Color color ) throws IOException
    {
        ColorSpace colorSpace = color.getColorSpace();
        if( colorSpace.getType() == ColorSpace.TYPE_RGB )
        {
            setStrokingColor( color.getRed(), color.getGreen(), color.getBlue() );
        }
        else if( colorSpace.getType() == ColorSpace.TYPE_GRAY )
        {
            color.getColorComponents( colorComponents );
            setStrokingColor( colorComponents[0] );
        }
        else if( colorSpace.getType() == ColorSpace.TYPE_CMYK )
        {
            color.getColorComponents( colorComponents );
            setStrokingColor( colorComponents[0], colorComponents[2], colorComponents[2], colorComponents[3] );
        }
        else
View Full Code Here


     * @param color The color to set.
     * @throws IOException If an IO error occurs while writing to the stream.
     */
    public void setNonStrokingColor( Color color ) throws IOException
    {
        ColorSpace colorSpace = color.getColorSpace();
        if( colorSpace.getType() == ColorSpace.TYPE_RGB )
        {
            setNonStrokingColor( color.getRed(), color.getGreen(), color.getBlue() );
        }
        else if( colorSpace.getType() == ColorSpace.TYPE_GRAY )
        {
            color.getColorComponents( colorComponents );
            setNonStrokingColor( colorComponents[0] );
        }
        else if( colorSpace.getType() == ColorSpace.TYPE_CMYK )
        {
            color.getColorComponents( colorComponents );
            setNonStrokingColor( colorComponents[0], colorComponents[2], colorComponents[2], colorComponents[3] );
        }
        else
View Full Code Here

            return 0.0;
        }
    }

    public static double getGamma(GraphicsDevice screen) {
        ColorSpace cs = screen.getDefaultConfiguration().getColorModel().getColorSpace();
        if (cs.isCS_sRGB()) {
            return 2.2;
        } else {
            try {
                return ((ICC_ProfileRGB)((ICC_ColorSpace)cs).getProfile()).getGamma(0);
            } catch (Exception e) { }
View Full Code Here

    /**
     * Derialize the parameter ColorSpace object.
     */
    private static ColorSpace deserializeColorSpace(ObjectInputStream in)
        throws IOException, ClassNotFoundException {
            ColorSpace cs = null;
            int colorSpaceType = in.readInt();
      if (colorSpaceType == COLORSPACE_OTHERS) {
    if (in.readBoolean()) {
        String name = (String)in.readObject();
        try {
View Full Code Here

    private void readObject(ObjectInputStream in)
        throws IOException, ClassNotFoundException {
        ColorModel colorModel = null;

        // Read serialized form from the stream.
        ColorSpace cs = null;

        // Switch on first int which is a flag indicating the class.
        switch((int)in.readInt()) {
        case COLORMODEL_NULL:
            colorModel = null;
View Full Code Here

            dataType > DataBuffer.TYPE_DOUBLE ||
            numBands < 1 || numBands > 4) {
            return null;
        }

        ColorSpace cs = numBands <= 2 ?
                        ColorSpace.getInstance(ColorSpace.CS_GRAY) :
                        ColorSpace.getInstance(ColorSpace.CS_sRGB);

        boolean useAlpha = (numBands == 2) || (numBands == 4);
        int transparency = useAlpha ?
View Full Code Here

    /**
     * Derialize the parameter ColorSpace object.
     */
    private static ColorSpace deserializeColorSpace(ObjectInputStream in)
        throws IOException {
            ColorSpace cs = null;
            int colorSpaceType = in.readInt();
            if(colorSpaceType == COLORSPACE_ICC) {
                cs = new ICC_ColorSpace(ICC_Profile.getInstance(in));
            } else if(colorSpaceType == COLORSPACE_PREDEFINED) {
                cs = ColorSpace.getInstance(in.readInt());
View Full Code Here

      * @param out The <code>ObjectInputStream</code>.
      */
    private void readObject(ObjectInputStream in)
        throws IOException, ClassNotFoundException {
        // Read serialized form from the stream.
        ColorSpace cs = null;

        // Switch on first int which is a flag indicating the class.
        switch((int)in.readInt()) {
        case COLORMODEL_NULL:
            colorModel = null;
View Full Code Here

                    System.out.print(" " + sample);
                }
            System.out.println();


            ColorSpace defaultCs;
            if (ri.getColorModel().getNumComponents() == 1)
                defaultCs = JAIContext.linearGrayColorSpace;
            else
                defaultCs = JAIContext.sRGBColorSpace;

            ColorSpace cs = (profile == null) ?
                    defaultCs :
                    new ICC_ColorSpace(profile);
            ColorModel colorModel =
                    RasterFactory.createComponentColorModel(ri.getSampleModel().getDataType(),
                            cs,
View Full Code Here

        final ImageMetadata metadata = imageInfo.getMetadata();
        final ImageMetadataDirectory dir =
            metadata.getDirectoryFor( CIFFDirectory.class );
        if ( dir != null ) {
            final ImageMetaValue colorSpace = dir.getValue( CIFF_COLOR_SPACE );
            ColorSpace cs = JAIContext.sRGBColorSpace;
            if ( colorSpace != null )
                switch ( colorSpace.getIntValue() ) {
                    case CIFF_COLOR_SPACE_ADOBE_RGB:
                        cs = JAIContext.adobeRGBColorSpace;
                        break;
View Full Code Here

TOP

Related Classes of java.awt.color.ColorSpace

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.