Examples of ColorModel


Examples of java.awt.image.ColorModel

        if (numBands < 1 || numBands > 4) {
            return false;
        }

        // Palette images must be 1-banded, depth 8 or less
        ColorModel colorModel = im.getColorModel();
        if (colorModel instanceof IndexColorModel) {
            if (numBands != 1 || bitDepth > 8) {
                return false;
            }
        }
View Full Code Here

Examples of java.awt.image.ColorModel

        int minY = im.getMinY();
        int width = im.getWidth();
        int height = im.getHeight();
        int numBands = im.getSampleModel().getNumBands();
        int scansize = width*numBands;
        ColorModel colorModel = im.getColorModel();
        int[] pixels = new int[scansize];

        Rectangle rect = new Rectangle(minX, minY, width, 1);

        for (int i = 0; i < numConsumers; i++) {
View Full Code Here

Examples of java.awt.image.ColorModel

        int[] aHistory = new int[shadowSize];
        int historyIdx;

        int aSum;

        ColorModel srcColorModel = src.getColorModel();
        WritableRaster srcRaster = src.getRaster();
        int[] dstBuffer = ((DataBufferInt) dst.getRaster().getDataBuffer()).getData();

        int lastPixelOffset = right * dstWidth;
        float hSumDivider = 1.0f / size;
        float vSumDivider = opacity / size;

        // horizontal pass : extract the alpha mask from the source picture and
        // blur it into the destination picture
        for (int srcY = 0, dstOffset = left * dstWidth; srcY < srcHeight; srcY++) {

            // first pixels are empty
            for (historyIdx = 0; historyIdx < shadowSize; ) {
                aHistory[historyIdx++] = 0;
            }

            aSum = 0;
            historyIdx = 0;

            // compute the blur average with pixels from the source image
            for (int srcX = 0; srcX < srcWidth; srcX++) {

                int a = (int) (aSum * hSumDivider); // calculate alpha value
                dstBuffer[dstOffset++] = a << 24;   // store the alpha value only
                                                    // the shadow color will be added in the next pass

                aSum -= aHistory[historyIdx]; // substract the oldest pixel from the sum

                // extract the new pixel ...
                a = srcColorModel.getAlpha(srcRaster.getDataElements(srcX, srcY, null));
                aHistory[historyIdx] = a;   // ... and store its value into history
                aSum += a;                  // ... and add its value to the sum

                if (++historyIdx >= shadowSize) {
                    historyIdx -= shadowSize;
View Full Code Here

Examples of java.awt.image.ColorModel

        }
        return xform;
    }

    private static RenderedImage systemColorSpaceImage(RenderedImage image) {
        ColorModel colors = image.getColorModel();
        ColorSpace space = colors.getColorSpace();
        if (space != null) {
            if (! space.equals(JAIContext.systemColorSpace)) {
                image = Functions.toColorSpace(
                    image, JAIContext.systemColorSpace, null
                );
View Full Code Here

Examples of java.awt.image.ColorModel

                                                         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.
        if((layout == null || !il.isValid(ImageLayout.COLOR_MODEL_MASK)) &&
           source.getSampleModel().getDataType() == DataBuffer.TYPE_BYTE &&
           sm.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

Examples of java.awt.image.ColorModel

* </ul>
*/
class FastImageFactory {

    static RenderedImage systemColorSpaceImage(RenderedImage image) {
        ColorModel colors = image.getColorModel();
        ColorSpace space = colors.getColorSpace();
        if (space != null) {
            if (! space.equals(JAIContext.systemColorSpace)) {
                image = Functions.toColorSpace(
                    image, JAIContext.systemColorSpace, null
                );
View Full Code Here

Examples of java.awt.image.ColorModel

     * the given image will be successfully encoded by the PNG
     * encoder, as it only performs a very superficial analysis of
     * the image structure.
     */
    public static PNGEncodeParam getDefaultEncodeParam(RenderedImage im) {
        ColorModel colorModel = im.getColorModel();
        if (colorModel instanceof IndexColorModel) {
            return new PNGEncodeParam.Palette();
        }

        SampleModel sampleModel = im.getSampleModel();
View Full Code Here

Examples of java.awt.image.ColorModel

                                                                 lineStride,
                                                                 bandOffsets);
            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

Examples of java.awt.image.ColorModel

        ImageLayout il = new ImageLayout(source);

        // If a layout containing a valid ColorModel field is supplied then
        // reset the ColorModel if it is compatible with the SampleModel.
        if(layout != null && layout.isValid(ImageLayout.COLOR_MODEL_MASK)) {
            ColorModel colorModel = layout.getColorModel(null);
            if(JDKWorkarounds.areCompatibleDataModels(source.getSampleModel(),
                                                      colorModel)) {
                il.setColorModel(colorModel);
            }
        }
View Full Code Here

Examples of java.awt.image.ColorModel

        // If the source has an IndexColorModel, override the default setting
        // in OpImage. The dest shall have exactly the same SampleModel and
        // ColorModel as the source.
        // Note, in this case, the source should have an integral data type.
        ColorModel srcColorModel = source.getColorModel();
        if (srcColorModel instanceof IndexColorModel) {
             sampleModel = source.getSampleModel().createCompatibleSampleModel(
                                                   tileWidth, tileHeight);
             colorModel = srcColorModel;
        }
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.