Package java.awt.image

Examples of java.awt.image.ColorModel


        for(int i = 0; i < numBands; i++) {
            bits[i] = dtSize;
        }
        int transparency = hasAlpha ?
            Transparency.TRANSLUCENT : Transparency.OPAQUE;
        ColorModel cm = new ComponentColorModel(cs, bits,
                                                hasAlpha, isAlphaPremultiplied,
                                                transparency,
                                                DataBuffer.TYPE_BYTE);
        il.setColorModel(cm);
View Full Code Here


            sm = RasterFactory.createComponentSampleModel(sm, dataType, w, h,
                                                          sm.getNumBands());
            il.setSampleModel(sm);

            // Clear the ColorModel mask if needed.
            ColorModel cm = il.getColorModel(null);
            if(cm != null &&
               !JDKWorkarounds.areCompatibleDataModels(sm, cm)) {
                // Clear the mask bit if incompatible.
                il.unsetValid(ImageLayout.COLOR_MODEL_MASK);
            }
View Full Code Here

            }
        }

        RenderedImage source = (RenderedImage)paramBlock.getSource(0);
        Raster pattern = source.getData();
        ColorModel colorModel = source.getColorModel();
        // Get image width and height from the parameter block
        int width = paramBlock.getIntParameter(0);
        int height = paramBlock.getIntParameter(1);
View Full Code Here

                                               ImageLayout layout) {

        // Contingent variables.
        RenderedImage source0 = null;
        SampleModel targetSM = null;
        ColorModel targetCM = null;

        // Get source count (might be zero).
        int numSources = sources.size();

        if(numSources > 0) {
View Full Code Here

                                                          sm.getHeight(),
                                                          1);
            il.setSampleModel(sm);

            // Clear the ColorModel mask if needed.
            ColorModel cm = il.getColorModel(null);
            if(cm != null &&
               !JDKWorkarounds.areCompatibleDataModels(sm, cm)) {
                // Clear the mask bit if incompatible.
                il.unsetValid(ImageLayout.COLOR_MODEL_MASK);
            }
        }

        // Set an IndexColorModel on the image if:
        // a. none is provided in the layout;
        // b. source, destination, and colormap have byte data type;
        // c. the colormap has 3 bands; and
        // d. the source ColorModel is either null or is non-null
        //    and has a ColorSpace equal to CS_sRGB.
        if((layout == null || !il.isValid(ImageLayout.COLOR_MODEL_MASK)) &&
           source.getSampleModel().getDataType() == DataBuffer.TYPE_BYTE &&
           il.getSampleModel(null).getDataType() == DataBuffer.TYPE_BYTE &&
           colormap.getDataType() == DataBuffer.TYPE_BYTE &&
           colormap.getNumBands() == 3) {
            ColorModel cm = source.getColorModel();
            if(cm == null ||
               (cm != null && cm.getColorSpace().isCS_sRGB())) {
                int size = colormap.getNumEntries();
                byte[][] cmap = new byte[3][256];
                for(int i = 0; i < 3; i++) {
                    byte[] band = cmap[i];
                    byte[] data = colormap.getByteData(i);
View Full Code Here

        // data depth.
        if (numSources > 1 && !layout.isValid(ImageLayout.SAMPLE_MODEL_MASK)) {
            // Determine the min number of bands and max range of data

            SampleModel sm = source0.getSampleModel();
            ColorModel cm = source0.getColorModel();
            int dtype0 = getAppropriateDataType(sm);
            int bands0 = getBandCount(sm, cm);
            int dtype = dtype0;
            int bands = bands0;
View Full Code Here

                    sm.getNumBands() > 4) {
                    return false;
                }
            }

            ColorModel cm = layout.getColorModel(null);
            if (cm != null && (!(cm instanceof ComponentColorModel))) {
                return false;
            }
        }
View Full Code Here

        if (!useMlib()) {    // mediaLib is not available
            return false;
        }

        SampleModel sm = image.getSampleModel();
        ColorModel cm = image.getColorModel();

        return (sm instanceof ComponentSampleModel &&
                sm.getNumBands() <= 4 &&
                (cm == null || cm instanceof ComponentColorModel));
    }
View Full Code Here

                                                              sm.getHeight(),
                                                              nBands);
    il.setSampleModel(sm);   // newly added

                // Clear the ColorModel mask if needed.
                ColorModel cm = layout.getColorModel(null);
                if(cm != null &&
                   !JDKWorkarounds.areCompatibleDataModels(sm, cm)) {
                    // Clear the mask bit if incompatible.
                    il.unsetValid(ImageLayout.COLOR_MODEL_MASK);
                }
View Full Code Here

                                                         sm.getHeight(),
                                                         1);
      il.setSampleModel(sm);

            // Clear the ColorModel mask if needed.
            ColorModel cm = il.getColorModel(null);
            if(cm != null &&
               !JDKWorkarounds.areCompatibleDataModels(sm, cm)) {
                // Clear the mask bit if incompatible.
                il.unsetValid(ImageLayout.COLOR_MODEL_MASK);
            }
        }

        // Determine whether a larger bit depth is needed.
        int numColorMapBands = colorMap.getNumBands();
        int maxIndex = 0;
        for(int i = 0; i < numColorMapBands; i++) {
            maxIndex = Math.max(colorMap.getOffset(i) +
                                colorMap.getNumEntries() - 1,
                                maxIndex);
        }

        // Create a deeper SampleModel if needed.
        if((maxIndex > 255 && sm.getDataType() == DataBuffer.TYPE_BYTE) ||
           (maxIndex > 65535 && sm.getDataType() != DataBuffer.TYPE_INT)) {
            int dataType = maxIndex > 65535 ?
                DataBuffer.TYPE_INT : DataBuffer.TYPE_USHORT;
            sm =
                RasterFactory.createComponentSampleModel(sm,
                                                         dataType,
                                                         sm.getWidth(),
                                                         sm.getHeight(),
                                                         1);
      il.setSampleModel(sm);

            // Clear the ColorModel mask if needed.
            ColorModel cm = il.getColorModel(null);
            if(cm != null &&
               !JDKWorkarounds.areCompatibleDataModels(sm, cm)) {
                // Clear the mask bit if incompatible.
                il.unsetValid(ImageLayout.COLOR_MODEL_MASK);
            }
        }

        // Set an IndexColorModel on the image if:
        // a. none is provided in the layout;
        // b. source and colormap have byte data type;
        // c. the colormap has 3 bands;
        // d. destination has byte or ushort data type.
        if((layout == null || !il.isValid(ImageLayout.COLOR_MODEL_MASK)) &&
           source.getSampleModel().getDataType() == DataBuffer.TYPE_BYTE &&
           (sm.getDataType() == DataBuffer.TYPE_BYTE ||
            sm.getDataType() == DataBuffer.TYPE_USHORT) &&
           colorMap.getDataType() == DataBuffer.TYPE_BYTE &&
           colorMap.getNumBands() == 3) {
            ColorModel cm = source.getColorModel();
            if(cm == null ||
               (cm != null && cm.getColorSpace().isCS_sRGB())) {
                int size = colorMap.getNumEntries();
                byte[][] cmap = new byte[3][maxIndex+1];
                for(int i = 0; i < 3; i++) {
                    byte[] band = cmap[i];
                    byte[] data = colorMap.getByteData(i);
View Full Code Here

TOP

Related Classes of java.awt.image.ColorModel

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.