if ( srcRaster instanceof PixelInterleavedRasterData && getView().dataInfo.bands == dataInfo.bands ) { int srcRasterPosx = raster.getView().x + srcX; int srcRasterPosy = raster.getView().y + srcY; int effectiveCols = raster.getColumns(); int effectiveRows = raster.getRows(); } else if ( srcRasterPosx >= raster.getOriginalWidth() ) { srcRasterPosx = raster.getOriginalWidth(); } else if ( srcRasterPosy >= raster.getOriginalHeight() ) { srcRasterPosy = raster.getOriginalHeight(); if ( ( srcRasterPosx + effectiveCols ) >= raster.getOriginalWidth() ) { effectiveCols = raster.getOriginalWidth() - srcRasterPosx; if ( ( srcRasterPosy + effectiveRows ) >= raster.getOriginalHeight() ) { effectiveRows = raster.getOriginalHeight() - srcRasterPosy; srcRasterPosx -= raster.getView().x; srcRasterPosy -= raster.getView().y; int subWidth = clampSize( getColumns(), dstX, effectiveCols, 0, width ); int subHeight = clampSize( getRows(), dstY, effectiveRows, 0, height ); ByteBuffer srcData = raster.getByteBuffer().asReadOnlyBuffer();
@Override protected ByteBufferRasterData createCompatibleEmptyRasterData() { return new PixelInterleavedRasterData( getView(), getOriginalWidth(), getOriginalHeight(), dataAccess.getReader(), this.dataInfo, false ); }
@Override public RasterData createCompatibleWritableRasterData( RasterRect sampleDomain, BandType[] bands ) { // a new raster will be created, the old information should be discarded. RasterDataInfo newRasterInfo = createRasterDataInfo( bands ); return new PixelInterleavedRasterData( new DataView( sampleDomain, newRasterInfo ), sampleDomain.width, sampleDomain.height, null, newRasterInfo, true ); }
@Override public PixelInterleavedRasterData createCompatibleRasterData( DataView view ) { return new PixelInterleavedRasterData( view, getOriginalWidth(), getOriginalHeight(), dataAccess.getReader(), dataInfo, false ); }
@Override public void setPixel( int x, int y, byte[] result ) { if ( getView().dataInfo.bands != dataInfo.bands ) { // Is this a view on less bands? super.setPixel( x, y, result ); return; } ByteBuffer data = getByteBuffer(); data.position( calculatePos( x, y ) ); data.put( result, 0, dataInfo.noDataPixel.length ); }
private TextureTile getTextureTile( double minX, double minY, double maxX, double maxY ) { int width = (int) ( ( maxX - minX ) / res ); int height = (int) ( ( maxY - minY ) / res ); LOG.debug( "Fetching texture tile (" + width + "x" + height + ") via WMSClient." ); Envelope bbox = fac.createEnvelope( minX, minY, maxX, maxY, requestedCRS ); SimpleRaster raster = null; try { raster = getMapAsSimpleRaster( client, layers, width, height, bbox, requestedCRS, requestedFormat, true, true, requestTimeout ).first; LOG.debug( "Success" ); } catch ( IOException e ) { LOG.debug( "Failed: " + e.getMessage(), e ); // this must never happen, cause the above request uses errorsInImage=true throw new RuntimeException( e.getMessage() ); } PixelInterleavedRasterData rasterData = (PixelInterleavedRasterData) raster.getRasterData(); return new TextureTile( minX, minY, maxX, maxY, rasterData.getColumns(), rasterData.getRows(), rasterData.getByteBuffer(), true, true ); }
private void setSubset( PixelInterleavedRasterData targetData, int x0, int y0, int width, int height, RasterData sourceRaster ) { // clamp to maximum possible size int subWidth = min( targetData.getColumns() - x0, width, sourceRaster.getColumns() ); int subHeight = min( targetData.getRows() - y0, height, sourceRaster.getRows() ); byte[] tmp = new byte[targetData.getDataInfo().getDataSize()]; for ( int y = 0; y < subHeight; y++ ) { for ( int x = 0; x < subWidth; x++ ) { byte[] color = new byte[3]; byte[] c = new byte[1]; c = sourceRaster.getSample( x, y, 0, c ); color[0] = c[0]; c = sourceRaster.getSample( x, y, 1, c ); color[1] = c[0]; c = sourceRaster.getSample( x, y, 2, c ); color[2] = c[0]; if ( !shouldBeTransparent( color ) ) { targetData.setSample( x0 + x, y0 + y, 0, sourceRaster.getSample( x, y, 0, tmp ) ); targetData.setSample( x0 + x, y0 + y, 1, sourceRaster.getSample( x, y, 1, tmp ) ); targetData.setSample( x0 + x, y0 + y, 2, sourceRaster.getSample( x, y, 2, tmp ) ); } } } }
if ( rasterData.isOutside() ) { return null; Pair<ByteBuffer, RasterRect> data = rasterData.getDataRect(); int texWidth = data.second.width; int texHeight = data.second.height; ByteBuffer pixelBuffer = data.first; if ( !rasterData.isWithinDataArea() ) { if ( !rasterData.isOutside() ) {
/** * @return the loaded buffer and the rectangle for which the buffer has data. */ public Pair<ByteBuffer, RasterRect> getDataRect() { return new Pair<ByteBuffer, RasterRect>( getByteBuffer(), dataAccess.getDataRectangle() ); } }
switch ( dataInfo.interleaveType ) { case PIXEL: result = new PixelInterleavedRasterData( view, view.width, view.height, newReader, dataInfo ); break; case LINE:
@Override public byte[] getPixel( int x, int y, byte[] result ) { if ( getView().dataInfo.bands != dataInfo.bands ) { return super.getPixel( x, y, result ); } if ( result == null ) { result = new byte[dataInfo.noDataPixel.length]; } int pos = calculatePos( x, y ); if ( pos == -1 ) { System.arraycopy( dataInfo.noDataPixel, 0, result, 0, result.length ); } else { ByteBuffer data = getByteBuffer().asReadOnlyBuffer(); data.position( pos ); data.get( result, 0, dataInfo.noDataPixel.length ); } return result; }