Examples of ComponentColorModel


Examples of java.awt.image.ComponentColorModel

     */
    public ColorModel createColorModel( int bpc ) throws IOException
    {
        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
        int[] nBits = {bpc};
        ColorModel colorModel = new ComponentColorModel(cs, nBits, false,false,
                Transparency.OPAQUE,DataBuffer.TYPE_BYTE);
        return colorModel;

    }
View Full Code Here

Examples of java.awt.image.ComponentColorModel

                }

                ColorModel cm = null;
                WritableRaster wr = null;
                if (depth() == IPL_DEPTH_8U || depth() == IPL_DEPTH_8S) {
                    cm = new ComponentColorModel(cs, alpha,
                            false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
                    wr = Raster.createWritableRaster(new ComponentSampleModel(
                            DataBuffer.TYPE_BYTE, width(), height(), nChannels(), widthStep(),
                            offsets), null);
                } else if (depth() == IPL_DEPTH_16U) {
                    cm = new ComponentColorModel(cs, alpha,
                            false, Transparency.OPAQUE, DataBuffer.TYPE_USHORT);
                    wr = Raster.createWritableRaster(new ComponentSampleModel(
                            DataBuffer.TYPE_USHORT, width(), height(), nChannels(), widthStep()/2,
                            offsets), null);
                } else if (depth() == IPL_DEPTH_16S) {
                    cm = new ComponentColorModel(cs, alpha,
                            false, Transparency.OPAQUE, DataBuffer.TYPE_SHORT);
                    wr = Raster.createWritableRaster(new ComponentSampleModel(
                            DataBuffer.TYPE_SHORT, width(), height(), nChannels(), widthStep()/2,
                            offsets), null);
                } else if (depth() == IPL_DEPTH_32S) {
                    cm = new ComponentColorModel(cs, alpha,
                            false, Transparency.OPAQUE, DataBuffer.TYPE_INT);
                    wr = Raster.createWritableRaster(new ComponentSampleModel(
                            DataBuffer.TYPE_INT, width(), height(), nChannels(), widthStep()/4,
                            offsets), null);
                } else if (depth() == IPL_DEPTH_32F) {
                    cm = new ComponentColorModel(cs, alpha,
                            false, Transparency.OPAQUE, DataBuffer.TYPE_FLOAT);
                    wr = Raster.createWritableRaster(new ComponentSampleModel(
                            DataBuffer.TYPE_FLOAT, width(), height(), nChannels(), widthStep()/4,
                            offsets), null);
                } else if (depth() == IPL_DEPTH_64F) {
                    cm = new ComponentColorModel(cs, alpha,
                            false, Transparency.OPAQUE, DataBuffer.TYPE_DOUBLE);
                    wr = Raster.createWritableRaster(new ComponentSampleModel(
                            DataBuffer.TYPE_DOUBLE, width(), height(), nChannels(), widthStep()/8,
                            offsets), null);
                }
View Full Code Here

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

Examples of java.awt.image.ComponentColorModel

            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

Examples of java.awt.image.ComponentColorModel

        // 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

Examples of java.awt.image.ComponentColorModel

            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

Examples of java.awt.image.ComponentColorModel

            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

Examples of java.awt.image.ComponentColorModel

    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

Examples of java.awt.image.ComponentColorModel

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

Examples of java.awt.image.ComponentColorModel

        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
TOP
Copyright © 2018 www.massapi.com. 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.