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

This code example shows how to use the following methods:getHeight, getMinX, getMinY, getSampleModel, getWidth
    protected Raster pattern;
 
    /** Set up image layout. */ 
    private static ImageLayout layoutHelper(Raster pattern,
                                            ColorModel colorModel) {
        return new ImageLayout(pattern.getMinX(), pattern.getMinY(),
                               pattern.getWidth(), pattern.getHeight(),
                               pattern.getSampleModel(), colorModel);
    } 
 
    /** 
     * Constructs a PatternOpImage from a Raster. 
     * 
     * @param pattern The Raster pattern to be repeated. 
     * @param colorModel The output image ColorModel. 
     * @param width The output image width. 
     * @param height The output image height. 
     */ 
    public PatternOpImage(Raster pattern,
                          ColorModel colorModel,
7
CodeRank
This code example shows how to use the following methods:getHeight, getMinX, getMinY, getWidth
		this(destCM, DEFAULT_QUANTIZATION_COLORS, DEFAULT_ALPHA_TH);
	} 
 
	public WritableRaster createCompatibleDestRaster(Raster src) {
		return icm.createCompatibleWritableRaster(src
				.getWidth(), src.getHeight()).createWritableTranslatedChild(src.getMinX(), src.getMinY());
	} 
 
	public WritableRaster filter(Raster src, WritableRaster dest) {
		if (dest == null)
			dest = createCompatibleDestRaster(src);
		else { 
 
			if (dest.getSampleModel().getNumBands() != 1)
				throw new IllegalArgumentException(
						"The destination raster for the IverseColorMapRasterOp must one one bad."); 
		} 
		final int w = dest.getWidth();
		final int h = dest.getHeight();
		final int srcMinX = src.getMinX();
6
CodeRank
This code example shows how to use the following methods:createCompatibleWritableRaster, getBounds, getDataBuffer, getHeight, getMinX
      * @param out The <code>ObjectOutputStream</code>. 
      */ 
    private void writeObject(ObjectOutputStream out) throws IOException {
        Raster r;
 
        if (raster.getParent() != null) {
            // Use the child ratser to create another Raster 
            // containing data for the requested bounds but which does 
            // not share the SampleModel and DataBuffer of the parent. 
            // Fix : 4631478 
            r = raster.createCompatibleWritableRaster(raster.getBounds());
            ((WritableRaster)r).setRect(raster);
        } else { 
            r = raster;
        } 
 
        out.writeInt(r.getWidth());
        out.writeInt(r.getHeight());
        out.writeObject(SerializerFactory.getState(r.getSampleModel(), null));
        out.writeObject(SerializerFactory.getState(r.getDataBuffer(), null));

6
CodeRank
This code example shows how to use the following methods:getHeight, getMinX, getMinY, getWidth
     * @param raster The raster for which to construct a grid envelope. 
     * @param dimension Number of dimensions for this grid envelope. 
     *        Must be equals or greater than 2. 
     */ 
    public GeneralGridEnvelope(final Raster raster, final int dimension) {
        this(raster.getMinX(), raster.getMinY(), raster.getWidth(), raster.getHeight(), dimension);
    } 
 
    /** 
     * Constructs multi-dimensional grid envelope defined by a {@link RenderedImage}. 
     * The two first dimensions are set to the 
     * [{@linkplain RenderedImage#getMinX x} .. x+{@linkplain RenderedImage#getWidth width}-1] and 
     * [{@linkplain RenderedImage#getMinY y} .. y+{@linkplain RenderedImage#getHeight height}-1] 
     * inclusive ranges respectively. 
     * Extra dimensions (if any) are set to the [0..0] inclusive range. 
     * 
     * <p> 
     * Notice that this method ensure interoperability between {@link Raster} dimensions in Java2D style and  
     * {@link GridEnvelope} dimensions in ISO 19123 style providing that the user remember to add 1 to the  
     * {@link GridEnvelope#getHigh(int)} values. 
6
CodeRank
This code example shows how to use the following methods:getDataBuffer, getHeight, getSampleModel, getWidth
            } 
        } else { 
            sourceRaster = iioImage.getRaster();
        } 
 
        SampleModel model = sourceRaster.getSampleModel();
        int srcWidth = sourceRaster.getWidth();
        int srcHeight = sourceRaster.getHeight();
        int numBands = model.getNumBands();
         
        ColorModel colorModel = img.getColorModel();
        int pixelSize = colorModel.getPixelSize();
        int bytePixelSize = pixelSize / 8;
        int bitDepth = pixelSize / numBands;
         
        // byte per band 
        int bpb = bitDepth > 8 ? 2 : 1;
         
        boolean isInterlace = true;
        if (param instanceof PNGImageWriterParam) {

6
CodeRank
This code example shows how to use the following methods:getDataBuffer, getHeight, getNumDataElements, getSampleModel, getTransferType
            return; 
        } 
 
        if (ras != null) {
 
            traceObjStart(label, ras, sb, indent);
            indent += INDENT_INCR;
 
            if (isFlagSet(traceMask, F_ATTRIBUTES)) {
                traceField("width", ras.getWidth(), sb, indent);
                traceField("height", ras.getHeight(), sb, indent);
                traceField("numBands", ras.getNumDataElements(), sb, indent);
                traceField("numDataElements", ras.getNumDataElements(), sb, indent);
                traceField("transferType", ImageUtils.getDataTypeName(ras.getTransferType()), sb, indent);
            } 
 
            traceObj("dataBuffer", ras.getDataBuffer(), traceMask, sb, indent);
            traceObj("sampleModel", ras.getSampleModel(), traceMask, sb, indent);
 
            indent -= INDENT_INCR;

6
CodeRank
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
This code example shows how to use the following methods:getDataBuffer, getSampleModelTranslateX, getSampleModelTranslateY
        WritableRenderedImage im = new WrapperWRI(ras);
        return createWritable(im, bounds);
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getDataBuffer, getSampleModelTranslateX, getSampleModelTranslateY
        if ((xIDNew != xID) || (yIDNew != yID) || (dataBuffer == null)) {
            xID = xIDNew;
            yID = yIDNew;
            Raster tile = im.getTile(xID, yID);
 
            this.dataBuffer = tile.getDataBuffer();
            this.sampleModelTranslateX = tile.getSampleModelTranslateX();
            this.sampleModelTranslateY = tile.getSampleModelTranslateY();
        } 
    } 
 
    public int getSample(int x, int y, int b) {
        makeCurrent(x - boundsX, y - boundsY);
        return sampleModel.getSample(x - sampleModelTranslateX,
                                     y - sampleModelTranslateY,
                                     b,
                                     dataBuffer);
    } 
 
    public float getSampleFloat(int x, int y, int b) {
6
CodeRank
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
See Code Examples for Java 8 Raster Methods: