Package java.awt.image

Examples of java.awt.image.ComponentColorModel


     * @throws IOException If there is an error creating the color model.
     */
    public ColorModel createColorModel( int bpc ) throws IOException
    {       
        int[] nbBits = { bpc, bpc, bpc };
        ComponentColorModel componentColorModel =
                new ComponentColorModel( createColorSpace(),
                                         nbBits,
                                         false,                    
                                         false,             
                                         Transparency.OPAQUE,
                                         DataBuffer.TYPE_BYTE );
View Full Code Here


            bits[i] = dataTypeSize;
        }

        switch (dataType) {
        case DataBuffer.TYPE_BYTE:
            return new ComponentColorModel(colorSpace,
                                           bits,
                                           useAlpha,
                                           premultiplied,
                                           transparency,
                                           dataType);
        case DataBuffer.TYPE_USHORT:
            return new ComponentColorModel(colorSpace,
                                           bits,
                                           useAlpha,
                                           premultiplied,
                                           transparency,
                                           dataType);
        /// case DataBuffer.TYPE_SHORT:
            /// return new ShortComponentColorModel(colorSpace,
                                                /// bits,
                                                /// useAlpha,
                                                /// premultiplied,
                                                /// transparency);
        case DataBuffer.TYPE_INT:
            return new ComponentColorModel(colorSpace,
                                           bits,
                                           useAlpha,
                                           premultiplied,
                                           transparency,
                                           dataType);
View Full Code Here

        // Write serialized form to the stream.
        if(colorModel == null) {
            out.writeInt(COLORMODEL_NULL);
        } else if(colorModel instanceof ComponentColorModel) {
            ComponentColorModel cm = (ComponentColorModel)colorModel;
            int type = COLORMODEL_COMPONENT;
            if(colorModel instanceof FloatDoubleColorModel) {
                type = COLORMODEL_FLOAT_DOUBLE_COMPONENT;
            }
            out.writeInt(type);
            serializeColorSpace(cm.getColorSpace(), out); // ignore return
            if(type == COLORMODEL_COMPONENT) {
                out.writeObject(cm.getComponentSize());
            }
            out.writeBoolean(cm.hasAlpha());
            out.writeBoolean(cm.isAlphaPremultiplied());
            out.writeInt(cm.getTransparency());
            // Create a SampleModel to get the transferType. This is
            // absurd but is the only apparent way to retrieve this value.
            SampleModel sm = cm.createCompatibleSampleModel(1, 1);
            out.writeInt(sm.getTransferType());
        } else if(colorModel instanceof IndexColorModel) {
            IndexColorModel cm = (IndexColorModel)colorModel;
            out.writeInt(COLORMODEL_INDEX);
            int size = cm.getMapSize();
            int[] cmap = new int[size];
            cm.getRGBs(cmap);
            out.writeInt(cm.getPixelSize());
            out.writeInt(size);
            out.writeObject(cmap);
            out.writeBoolean(cm.hasAlpha());
            out.writeInt(cm.getTransparentPixel());
            // Create a SampleModel to get the transferType. This is
            // absurd but is the only apparent way to retrieve this value.
            SampleModel sm = cm.createCompatibleSampleModel(1, 1);
            out.writeInt(sm.getTransferType());
        } else if(colorModel instanceof DirectColorModel) {
            DirectColorModel cm = (DirectColorModel)colorModel;
            out.writeInt(COLORMODEL_DIRECT);
            boolean csSerialized =
                serializeColorSpace(cm.getColorSpace(), out);
            if(!csSerialized) {
                out.writeBoolean(cm.hasAlpha());
            }
            out.writeInt(cm.getPixelSize());
            out.writeInt(cm.getRedMask());
            out.writeInt(cm.getGreenMask());
            out.writeInt(cm.getBlueMask());
            if(csSerialized || cm.hasAlpha()) {
                out.writeInt(cm.getAlphaMask());
            }
            if(csSerialized) {
                out.writeBoolean(cm.isAlphaPremultiplied());
                // Create a SampleModel to get the transferType. This is
                // absurd but is the only apparent way to retrieve this
                // value.
                SampleModel sm = cm.createCompatibleSampleModel(1, 1);
                out.writeInt(sm.getTransferType());
            }
        } else {
            throw new RuntimeException(JaiI18N.getString("ColorModelState0"));
        }
View Full Code Here

            if((cs = deserializeColorSpace(in)) == null) {
                colorModel = null;
                return;
            }
            colorModel =
                new ComponentColorModel(cs, (int[])in.readObject(),
                                        in.readBoolean(), in.readBoolean(),
                                        in.readInt(), in.readInt());
            break;
        case COLORMODEL_INDEX:
            colorModel =
View Full Code Here

            if((cs = deserializeColorSpace(in)) == null) {
                colorModel = null;
                return;
            }
            colorModel =
                new ComponentColorModel(cs, (int[])in.readObject(),
                                        in.readBoolean(), in.readBoolean(),
                                        in.readInt(), in.readInt());
            break;
        case COLORMODEL_INDEX:
            colorModel =
View Full Code Here

    private void writeObject(ObjectOutputStream out) throws IOException {
        // Write serialized form to the stream.
        if(colorModel == null) {
            out.writeInt(COLORMODEL_NULL);
        } else if(colorModel instanceof ComponentColorModel) {
            ComponentColorModel cm = (ComponentColorModel)colorModel;
            int type = COLORMODEL_COMPONENT;
            if(colorModel instanceof FloatDoubleColorModel) {
                type = COLORMODEL_FLOAT_DOUBLE_COMPONENT;
            }
            out.writeInt(type);
            serializeColorSpace(cm.getColorSpace(), out); // ignore return
            if(type == COLORMODEL_COMPONENT) {
                out.writeObject(cm.getComponentSize());
            }
            out.writeBoolean(cm.hasAlpha());
            out.writeBoolean(cm.isAlphaPremultiplied());
            out.writeInt(cm.getTransparency());
            // Create a SampleModel to get the transferType. This is
            // absurd but is the only apparent way to retrieve this value.
            SampleModel sm = cm.createCompatibleSampleModel(1, 1);
            out.writeInt(sm.getTransferType());
        } else if(colorModel instanceof IndexColorModel) {
            IndexColorModel cm = (IndexColorModel)colorModel;
            out.writeInt(COLORMODEL_INDEX);
            int size = cm.getMapSize();
            int[] cmap = new int[size];
            cm.getRGBs(cmap);
            out.writeInt(cm.getPixelSize());
            out.writeInt(size);
            out.writeObject(cmap);
            out.writeBoolean(cm.hasAlpha());
            out.writeInt(cm.getTransparentPixel());
            // Create a SampleModel to get the transferType. This is
            // absurd but is the only apparent way to retrieve this value.
            SampleModel sm = cm.createCompatibleSampleModel(1, 1);
            out.writeInt(sm.getTransferType());
        } else if(colorModel instanceof DirectColorModel) {
            DirectColorModel cm = (DirectColorModel)colorModel;
            out.writeInt(COLORMODEL_DIRECT);
            boolean csSerialized =
                serializeColorSpace(cm.getColorSpace(), out);
            if(!csSerialized) {
                out.writeBoolean(cm.hasAlpha());
            }
            out.writeInt(cm.getPixelSize());
            out.writeInt(cm.getRedMask());
            out.writeInt(cm.getGreenMask());
            out.writeInt(cm.getBlueMask());
            if(csSerialized || cm.hasAlpha()) {
                out.writeInt(cm.getAlphaMask());
            }
            if(csSerialized) {
                out.writeBoolean(cm.isAlphaPremultiplied());
                // Create a SampleModel to get the transferType. This is
                // absurd but is the only apparent way to retrieve this
                // value.
                SampleModel sm = cm.createCompatibleSampleModel(1, 1);
                out.writeInt(sm.getTransferType());
            }
        } else {
            throw new RuntimeException(JaiI18N.getString("ColorModelProxy0"));
        }
View Full Code Here

import java.awt.*;

public class FrozenImage extends PlanarImage {
    static ImageLayout getsRGBImageLayout(RenderedImage image) {
        ImageLayout layout = new ImageLayout(image);
        layout.setColorModel(new ComponentColorModel(JAIContext.sRGBColorSpace, false, false,
                                                     Transparency.OPAQUE, DataBuffer.TYPE_BYTE));
        return layout;
    }
View Full Code Here

        Raster srcRaster =
           RasterFactory.createInterleavedRaster(dataType,
                                          tileWidth,tileHeight,bands,null);
        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
        int bits[] = {8,8,8};
        ComponentColorModel ccm =
           new ComponentColorModel(cs,bits,false,false,
                                   Transparency.OPAQUE,DataBuffer.TYPE_BYTE);

        source = new PatternOpImage(srcRaster, ccm, 0, 0, width, height);
    }
View Full Code Here

    }

    public static ComponentColorModel createComponentColorModel() {
        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
        int bits[] = {8, 8, 8};
        return new ComponentColorModel(cs, bits, false, false,
                                       Transparency.OPAQUE,
                                       DataBuffer.TYPE_BYTE);
    }
View Full Code Here

              int dataType,
                                                  int numBands,
              boolean isAlphaPremultiplied,
              int transparency) {

  ComponentColorModel ccm = null;
        int RGBBits[] = null;
        ColorSpace cs = null;
        switch(numBands) {
        case 2: // gray+alpha
            cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
            break;
        case 4: // RGB+alpha
            cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
            break;
        default:
            throw new IllegalArgumentException();
        }

        if(dataType == DataBuffer.TYPE_FLOAT) {
            ccm = new FloatDoubleColorModel(cs,
                                            true,
                                            isAlphaPremultiplied,
                                            transparency,
                                            dataType);
        } else { // all other types
            int componentSize = 0;
            switch(dataType) {
            case DataBuffer.TYPE_BYTE:
                componentSize = 8;
                break;
            case DataBuffer.TYPE_USHORT:
            case DataBuffer.TYPE_SHORT:
                componentSize = 16;
                break;
            case DataBuffer.TYPE_INT:
                componentSize = 32;
                break;
            default:
                throw new IllegalArgumentException();
            }

            RGBBits = new int[numBands];
            for(int i = 0; i < numBands; i++) {
                RGBBits[i] = componentSize;
            }

            ccm = new ComponentColorModel(cs,
                                          RGBBits,
                                          true,
                                          isAlphaPremultiplied,
                                          transparency,
                                          dataType);
View Full Code Here

TOP

Related Classes of java.awt.image.ComponentColorModel

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.