Saving & restoring a region of a VolatileImage
I have a VolatileImage and I would like to take a snapshot of a region of it and then restore this region at a later time. I cannot quite figure out how to do it.
So far, I have established that I need to firstly get the snapshot using the image.getSnapshot() method which creates a BufferedImage of the entire volatile image. Then it would seem I need to use the copy the bufferedImage.copyData() method to copy the region I want but that method requires a Raster. So first I have to create Raster. To do this I think I should use the Raster.createWritableRaster() method which requires a SampleModel and a Point. To create the SampleModel it looks like I should be using a SinglePixelPackedSampleModel. To create the SinglePixelPackedSampleModel I need to specify an array of bit masks.
What do I need to put into this bit mask array? Or, is there a simple way of doing this? It seems rather complicated! Perhaps someone has an example of this kind of thing?
And loving it,
(Replace the "SixFour" with numbers to email me)