Once you have a BufferedImage you could call getSubImage() and then getRaster() on that to get a WritableRaster. Then you don't have to create a Raster at all.
Another way is to get the Raster from the BufferedImage and use the instance methods createCompatibleWritableRaster() that will automatically copy the SampleModel of the original Raster. Hope that helps. > -----Original Message----- > From: Discussion list for Java 2D API > [mailto:[EMAIL PROTECTED] On Behalf Of > [EMAIL PROTECTED] > Sent: Tuesday, November 20, 2007 9:00 AM > To: [EMAIL PROTECTED] > Subject: [JAVA2D] 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, > > -Q > _________________________________________________ > [EMAIL PROTECTED] > (Replace the "SixFour" with numbers to email me) [Message > sent by forum member 'qu0ll' (qu0ll)] > > http://forums.java.net/jive/thread.jspa?messageID=246312 > > ============================================================== > ============= > To unsubscribe, send email to [EMAIL PROTECTED] and > include in the body of the message "signoff JAVA2D-INTEREST". > For general help, send email to [EMAIL PROTECTED] and > include in the body of the message "help". > =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".