The rasters aren't actually interleaved since Denis is only using
1 band.  Using the factory method is a good idea and is better than
writing your own SampleModel if there is no real need for one since
this will cause the image to fall into a custom case and that will
render slower.  SampleModels don't have an offset but Rasters
do.  Note the offsets variable below is the offset into the DataBuffer.
Denis could call that factory method multiple times to create the
multiple images, giving a different offset each time.

jeannette

> Mime-Version: 1.0
> X-Sent-Mail: on
> X-Sender-Ip: 128.64.14.101
> Content-Transfer-Encoding: 7bit
> Date: Thu, 17 Jun 1999 09:41:53 -0700
> From: Pete Cockerell <[EMAIL PROTECTED]>
> Subject: Re: BufferedImage and WriteableRaster problems
> Comments: To: Pete Cockerell <[EMAIL PROTECTED]>, Denis Riedijk
<[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
>
> Hi
>
> So in one of those head-slappingly embarrassing moments of realization, it
occurred to me on the train just now that my example had you trying to construct
an abstract class, ComponentSampleModel. What you'd really want is one of the
concrete subclasses, PixelInterleavedSampleModel. Moreover, you could do both
the sample model and raster in one call to a WriteableRaster factory (static)
method:
>
> createInterleavedRaster(dataBuffer, w, h, w*n, 1, offsets, origin);
>
> Even so, I would still ask yourself whether interleaving the resters like this
is such a good idea. If the only reason is to save calls by only having to do
the scaling operation once instead of n times, then I think you should probably
just construct a raster for each image in the first place. Unless each raster is
very small (say, less than 50 X 50), the overhead of calling the pixel
processing code once for each raster instead of once for all of them will
probably be negligible.
>
> Cheers,
> Pete
>
>
> ---
> Pete Cockerell
> California, USA
> http://www.best.com/~petec
>
>
>
> On Thu, 17 Jun 1999 17:12:20   Denis Riedijk wrote:
> >Thanks, I will try it in a minute to see if it will work. This is my first
> > experience with Java2D, so I am still trying to understand it all exactly,
the
> >construction of an image out of databuffers, samplemodels, rasters and
> >colormodels :-)
> >
> >But from what I have understood from the docs, this will probably be it.
> >
> >About my use for this:
> >I will have data (in a char array right now, but from what I understand it
must
> >become a short array now) which is scaled from 0-65535 (16 bits) This is
output
> >from different reconstruction programs. The user must be able to adjust the
> >intensity-thresholds of the image ( set minimum to be black and maximum to be
> >white, so standard value 0 will be black and value 65535 will be white, but
> >when the user want 16734 to be black I have to scale from 16734 to 65535)
> >This scaling of intensity must be done on all images, so therefore I can use
> >different IndexColorModels I believe. Right now in my JDK1.1.7 program I have
> >written a function to do this myself, but it is not too fast, and my most
ugly
> >piece of code (it is also very big) I think I can make it fast and small (and
> >nice :-) by using Java2D
> >
> >
> >Dhnis Riedijk
> >
> >
>
>
> --== Sent via Deja.com http://www.deja.com/ ==--
> Share what you know. Learn what you don't.

Reply via email to