Java 8 DirectColorModel - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 DirectColorModel class.

This code example shows how to use the following methods:getTransferType, isAlphaPremultiplied, getAlphaMask, getBlueMask, getGreenMask
                        .isAlphaPremultiplied(), ccm.getTransparency(), ccm
                        .getTransferType());
        } else if (old_cm instanceof DirectColorModel) {
            DirectColorModel dcm = (DirectColorModel) old_cm;
 
            int old_mask = dcm.getRedMask() | dcm.getGreenMask()
                    | dcm.getBlueMask() | dcm.getAlphaMask();
 
            int old_bits = count_bits_in_mask(old_mask);
 
            return new DirectColorModel(cs, old_bits, dcm.getRedMask(), dcm
                    .getGreenMask(), dcm.getBlueMask(), dcm.getAlphaMask(), dcm
                    .isAlphaPremultiplied(), dcm.getTransferType());
        } 
        // else if (old_cm instanceof PackedColorModel) 
        // { 
        // PackedColorModel pcm = (PackedColorModel) old_cm; 
        // 
        // // int old_mask = dcm.getRedMask() | dcm.getGreenMask() 
        // // | dcm.getBlueMask() | dcm.getAlphaMask(); 
6
CodeRank
This code example shows how to use the following methods:getTransferType, getBlueMask, getGreenMask, getRedMask
        try{ 
            raster = cm.createCompatibleWritableRaster(width, height);
            isIntRGB = false;
            if(cm instanceof DirectColorModel){
                DirectColorModel dcm = (DirectColorModel) cm;
                if(dcm.getTransferType() == DataBuffer.TYPE_INT &&
                        dcm.getRedMask() == 0xff0000 &&
                        dcm.getGreenMask() == 0xff00 &&
                        dcm.getBlueMask() == 0xff){
                    isIntRGB = true;
                } 
            } 
        }catch(Exception e){
            cm = ColorModel.getRGBdefault();
            raster = cm.createCompatibleWritableRaster(width, height);
            isIntRGB = true;
        } 
    } 
 
    private /*synchronized*/ void imageUpdate(Image img, int infoflags, int x, int y,
6
CodeRank
This code example shows how to use the following methods:getPixelSize, getBlueMask, getGreenMask, getRedMask
                0, 0, new int[] {0, 1, 2 } 
            ); 
            // create a ColorModel that represents the one of the ARGB except the alpha channel: 
            DirectColorModel cm = (DirectColorModel) bi.getColorModel();
            DirectColorModel newCM = new DirectColorModel(
                cm.getPixelSize(), cm.getRedMask(),
                cm.getGreenMask(), cm.getBlueMask());
            // now create the new buffer that is used ot write the image: 
            BufferedImage rgbBuffer = new BufferedImage(newCM,
                newRaster, false, null);
            writer.write(null, new IIOImage(rgbBuffer, null,
                null), param);
        } else { 
            writer.write(null, new IIOImage(bi, null, null),
                param);
        } 
    } 
 
    /** 
     * Saves the image. Image format is deduced from filename. 
6
CodeRank
This code example shows how to use the following methods:isAlphaPremultiplied
                    0x000000ff, 
                    0xff000000); 
            raster = WritableRaster.createPackedRaster(buffer, width, height, width,
                    new int[] { 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 }, null); 
        } else { 
            colorModel = new DirectColorModel(24,
                    0x00ff0000, 
                    0x0000ff00, 
                    0x000000ff); 
            raster = WritableRaster.createPackedRaster(buffer, width, height, width,
                    new int[] { 0x00ff0000, 0x0000ff00, 0x000000ff }, null); 
        } 
        return new BufferedImage(colorModel, raster, colorModel.isAlphaPremultiplied(), new Properties());
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getAlphaMask, getBlueMask, getGreenMask, getRedMask
This code example shows how to use the following methods:getAlphaMask, getBlueMask, getGreenMask, getRedMask
This code example shows how to use the following methods:getAlphaMask, getBlueMask, getGreenMask
    } 
 
    @Test(expected = RasterFormatException.class)
    public void testCreateContextInvalidSrcRedMask() throws Exception {
 
        srcColorModel = new DirectColorModel(Integer.SIZE, 0, srcColorModel.getGreenMask(),
                srcColorModel.getBlueMask(), srcColorModel.getAlphaMask());
        composite.createContext(srcColorModel, destColorModel, hints);
        PowerMockito.verifyNoMoreInteractions(srcColorModel, destColorModel);
        verifyZeroInteractions(hints);
    } 
 
    @Test(expected = RasterFormatException.class)
    public void testCreateContextInvalidSrcGreenMask() throws Exception {
 
        srcColorModel = new DirectColorModel(Integer.SIZE, srcColorModel.getRedMask(), 0, srcColorModel.getBlueMask(),
                srcColorModel.getAlphaMask());
        composite.createContext(srcColorModel, destColorModel, hints);
        PowerMockito.verifyNoMoreInteractions(srcColorModel, destColorModel);
        verifyZeroInteractions(hints);
4
CodeRank
This code example shows how to use the following methods:
        WritableRaster raster = new IntegerInterleavedRaster(sampleModel, 
                j2DBuf, new Point(0, 0)); 
 
        // Finally create a screen accessible colour model and wrap the raster 
        // in a buffered image. 
        ColorModel colorModel = new DirectColorModel(24, 0x00ff0000, // Red 
                0x0000ff00, // Green 
                0x000000ff // Blue 
        // 0xff000000 // Alpha 
        ); 
        BufferedImage image = new BufferedImage(colorModel, raster, false, null); 
 
        return image; 
    } 
} 
4
CodeRank
This code example shows how to use the following methods:getAlphaMask, getBlueMask, getGreenMask, getRedMask
        if(sampleModel.getDataType() != DataBuffer.TYPE_INT)
            throw new IllegalArgumentException("colorModel's transferType should be DataBuffer.TYPE_INT");
 
        // Check red, green, blue and alpha mask 
        DirectColorModel dcm = (DirectColorModel)colorModel;
        if(dcm.getRedMask() != 0x00ff0000)
            throw new IllegalArgumentException("red mask in source should be 0x00ff0000");
        if(dcm.getGreenMask() != 0x0000ff00)
            throw new IllegalArgumentException("green mask in source should be 0x0000ff00");
        if(dcm.getBlueMask() != 0x000000ff)
            throw new IllegalArgumentException("blue mask in source should be 0x000000ff");
        if(dcm.getAlphaMask() != 0xff000000)
            throw new IllegalArgumentException("alpha mask in source should be 0xff000000");
    } 
 
    private boolean isCompatible(ColorModel colorModel,
                                 SampleModel sampleModel){
        ColorSpace cs = colorModel.getColorSpace();
        // Check that model is sRGB or linear RGB 
        if((cs != ColorSpace.getInstance(ColorSpace.CS_sRGB))
4
CodeRank
This code example shows how to use the following methods:
                                         in.readInt(), in.readInt(),
                                         in.readInt(), in.readBoolean(),
                                         in.readInt());
            } else if(in.readBoolean()) {
                colorModel =
                    new DirectColorModel(in.readInt(), in.readInt(),
                                         in.readInt(), in.readInt(),
                                         in.readInt());
            } else { 
                colorModel =
                    new DirectColorModel(in.readInt(), in.readInt(),
                                         in.readInt(), in.readInt());
            } 
            break; 
        default: 
            // NB: Should never get here. 
            throw new RuntimeException(JaiI18N.getString("ColorModelProxy1"));
        } 
    } 
} 
4
CodeRank
See Code Examples for Java 8 DirectColorModel Methods: