Java 8 WritableRaster - 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 WritableRaster class.

This code example shows how to use the following methods:getHeight, getWidth, setDataElements
        if(dstIn != dstOut){
            if(!dstCM.isCompatibleRaster(dstOut)) {
                // awt.4A=The dstOut raster is incompatible with dst ColorModel 
                throw new IllegalArgumentException(Messages.getString("awt.4A")); //$NON-NLS-1$
            } 
            dstOut.setDataElements(0, 0, dstIn);
        } 
        WritableRaster src;
        if(srcIn instanceof WritableRaster){
            src = (WritableRaster) srcIn;
        }else{ 
            src = srcIn.createCompatibleWritableRaster();
            src.setDataElements(0, 0, srcIn);
        } 
        srcSurf = new ImageSurface(srcCM, src);
        dstSurf = new ImageSurface(dstCM, dstOut);
 
        int w = Math.min(srcIn.getWidth(), dstOut.getWidth());
        int h = Math.min(srcIn.getHeight(), dstOut.getHeight());
 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getMinX, getMinY, createWritableTranslatedChild
        return ret.createTranslatedChild(ret.getMinX()+getMinX(),
                                         ret.getMinY()+getMinY());
    } 
 
    public WritableRaster copyData(WritableRaster wr) {
        WritableRaster wr2 = wr.createWritableTranslatedChild
            (wr.getMinX()-getMinX(),
             wr.getMinY()-getMinY());
 
        GraphicsUtil.copyData(bi.getRaster(), wr2);
 
        /* This was the original code. This is _bad_ since it causes a 
         * multiply and divide of the alpha channel to do the draw 
         * operation.  I believe that at some point I switched to 
         * drawImage in order to avoid some issues with 
         * BufferedImage's copyData implementation but I can't 
         * reproduce them now. Anyway I'm now using GraphicsUtil which 
         * should generally be as fast if not faster... 
         */ 
        /* 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getBounds, getMinX, getMinY, createWritableTranslatedChild
    public void genRect(WritableRaster wr) {
        if (me2src == null)
            return; 
 
        Rectangle srcR
            = me2src.createTransformedShape(wr.getBounds()).getBounds();
 
        // System.out.println("Affine wrR: " + wr.getBounds()); 
        // System.out.println("Affine srcR: " + srcR); 
 
        // Outset by two pixels so we get context for interpolation... 
        srcR.setBounds(srcR.x-1, srcR.y-1, srcR.width+2, srcR.height+2);
 
        // Don't try and get data from src that it doesn't have... 
        CachableRed src = (CachableRed)getSources().get(0);
 
        // Raster srcRas = src.getData(srcR); 
 
        if ( ! srcR.intersects(src.getBounds()) )
            return; 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:createTranslatedChild, getHeight, getWidth, createWritableChild
    public Raster getRaster(int x, int y, int width, int height){
 
        // System.out.println("GetRaster: [" + x + ", " + y + ", "  
        //                    + width + ", " + height + "]"); 
        if ((raster == null)             ||
            (raster.getWidth() < width)  ||
            (raster.getHeight() < height)) {
            raster = rasterCM.createCompatibleWritableRaster(width, height);
        } 
 
        WritableRaster wr
            = raster.createWritableChild(0, 0, width, height, x, y, null);
 
        tiled.copyData(wr);
        GraphicsUtil.coerceData(wr, tiled.getColorModel(), 
                                rasterCM.isAlphaPremultiplied());
 
        // On Mac OS X it always wants the raster at 0,0 if the 
        // requested width and height matches raster we can just 
        // return it.  Otherwise we create a translated child that 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getMinX, getMinY, createWritableTranslatedChild
        return ret.createTranslatedChild(ret.getMinX()+deltaX,
                                         ret.getMinY()+deltaY);
    } 
 
    public WritableRaster copyData(WritableRaster wr) {
        WritableRaster wr2 = wr.createWritableTranslatedChild
            (wr.getMinX()-deltaX, wr.getMinY()-deltaY);
 
        getSource().copyData(wr2);
 
        return wr;
    } 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:createWritableTranslatedChild
        WritableRaster tmpR1=null, tmpR2=null;
 
        tmpR1 = srcCM.createCompatibleWritableRaster(r.width, r.height);
        { 
            WritableRaster fill;
            fill = tmpR1.createWritableTranslatedChild(r.x, r.y);
            src.copyData(fill);
        } 
        if (srcCM.hasAlpha() && !srcCM.isAlphaPremultiplied())
            GraphicsUtil.coerceData(tmpR1, srcCM, true);
 
        // For the blur box approx we can use dest as our intermediate 
        // otherwise we let it default to null which means we create a new 
        // one... 
 
        // this lets the Vertical conv know how much is junk, so it 
        // doesn't bother to convolve the top and bottom edges 
        int skipX;
        // long t1 = System.currentTimeMillis(); 
        if (xinset == 0) {

5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getBounds, getNumBands
        CachableRed srcRed = (CachableRed)getSources().get(0);
 
        SampleModel sm = srcRed.getSampleModel();
        if (sm.getNumBands() == 1)
            // Already one band of data so we just use it... 
            return srcRed.copyData(wr);
 
        PadRed.ZeroRecter.zeroRect(wr);
        Raster srcRas = srcRed.getData(wr.getBounds());
        AbstractRed.copyBand(srcRas, srcRas.getNumBands()-1, wr, 
                             wr.getNumBands()-1);
        return wr;
    } 
 
}     
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getHeight, getWidth, createWritableChild
        int th = sm.getHeight();
        w = (((w+tw-1)/tw)+1)*tw;
        h = (((h+th-1)/th)+1)*th;
 
        if ((workingBaseRaster == null) ||
            (workingBaseRaster.getWidth()  < w) ||
            (workingBaseRaster.getHeight() < h)) {
 
            sm = sm.createCompatibleSampleModel(w, h);
 
            workingBaseRaster
                = Raster.createWritableRaster(sm, new Point(0,0));
        } 
 
        int tgx = -rootCR.getTileGridXOffset();
        int tgy = -rootCR.getTileGridYOffset();
        int xt, yt;
        if (tgx>=0) xt = tgx/tw;
        else        xt = (tgx-tw+1)/tw;
        if (tgy>=0) yt = tgy/th;

5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getHeight, getWidth, createWritableChild
        // this is especially needed for jpeg files where imageio seems to produce wrong jpeg files right now... 
        if (bi.getType() == BufferedImage.TYPE_INT_ARGB
            && !alpha) {
            // create a new BufferedImage that uses a WritableRaster of bi, with all the bands except the alpha band: 
            WritableRaster raster = bi.getRaster();
            WritableRaster newRaster = raster.createWritableChild(
                0, 0, raster.getWidth(), raster.getHeight(),
                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 { 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getDataBuffer, getHeight, getSampleModel, getWidth
        // we know the DataBuffer is of type DataBufferInt and the SampleModel 
        // is SinglePixelPackedSampleModel. 
        // Adjust for initial offset in DataBuffer and also for the scanline 
        // stride. 
        // 
        DataBufferInt rasterDB = (DataBufferInt)raster.getDataBuffer();
        int[] pixels = rasterDB.getBankData()[0];
        int off = rasterDB.getOffset();
        int scanlineStride = ((SinglePixelPackedSampleModel)
                              raster.getSampleModel()).getScanlineStride();
        int adjust = scanlineStride - w;
 
        fillRaster(pixels, off, adjust, x, y, w, h); //delegate to subclass.
 
        GraphicsUtil.coerceData(raster, dataModel,
                                model.isAlphaPremultiplied());
 
 
        return raster;
    } 

5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Java 8 WritableRaster Methods: