private void setSubset( PixelInterleavedRasterData targetData, int x0, int y0, int width, int height,
RasterData sourceRaster ) {
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 ) );
}
}
}
}