commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Damjan Jovanovic <damjan....@gmail.com>
Subject Re: [sanselan] how to access raw pixels?
Date Mon, 18 Apr 2011 14:58:00 GMT
On Mon, Apr 18, 2011 at 4:30 PM, Gary Lucas <gwlucas@sonalysts.com> 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: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message