Thanks for the suggestion. It sounds a lot better than using getRGB() (even the array version) on the BufferedImage.
Gary -----Original Message----- From: Damjan Jovanovic [mailto:[email protected]] Sent: Monday, April 18, 2011 10:58 AM To: Commons Users List Subject: Re: [sanselan] how to access raw pixels? On Mon, Apr 18, 2011 at 4:30 PM, Gary Lucas <[email protected]> wrote: > I have an application for which I am considering the use of Sanselan to > process GeoTIFF images, but am unsure how to use the API to support one of my > requirements. > > The main Sanselan class provides an API that reads the TIFF and produces a > BufferedImage. But my need is to get at the raw pixels in a random-access > sort of pattern. While I could just use the BufferedImage.getRGB method to > read pixels, I was wondering if there was a way to "cut out the middle man" > and get at the pixel data directly (the hope being that doing so would > improve the time required to load and process the images). I've been looking > through the Sanselan source code (the documentation is a bit sparse), but am > having a bit of trouble figuring out the best way to proceed. > > Does anyone have an example snippet of code or white paper explaining how to > do this? Is it even possible? > > Gary Hi Gary Sanselan only returns BufferedImage, but the raw pixel data can be obtained from the BufferedImage. Call getRaster() to obtain a WritableRaster, then call the methods on it or even the getDataBuffer() method which return a DataBuffer subclass (depending on the BufferedImage's SampleModel and ColorModel) which can give you an array of byte/short/int etc. Good luck Damjan Jovanovic --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
