Quantcast
Channel: Forums - ArcObjects SDKs
Viewing all articles
Browse latest Browse all 1374

JAVA Raster: Writing to a pixel block

$
0
0
Hi,

Can someone please help with the Java code to write values into a pixel block!?

Code:

IRasterDataset streamOrder  = rasterWorkSpace.openRasterDataset("streamOrder.tif");
RasterDataset streamOrderRas = (RasterDataset)streamOrder;

RasterBand streamOrderBand = new RasterBand(streamOrderRas.item(0));

IPnt size1 = new DblPnt();
size1.setCoords(streamOrderBand.getWidth(), streamOrderBand.getHeight());

PixelBlock writePixBlock = (PixelBlock)(streamOrderBand.createPixelBlock(size1));
IPnt tlc1 = new DblPnt();
tlc1.setCoords(0, 0);
streamOrderBand.read(tlc1, writePixBlock);

Object vPixels = writePixBlock.getSafeArray(0);

I am not able to proceed further! I cannot cast this vPixels into anything, hence I am not able to access or alter the values inside.

Will changing the safe array and setting it to the pixel block be enough? I also tried IPixelBlock3 but it did not work.

Please can some one show a working example.

Thanks,
Avishek

Viewing all articles
Browse latest Browse all 1374

Trending Articles