>>>>> "TH" == Ted Hill <[EMAIL PROTECTED]> writes:
TH> Dmitri, Thanks for the response.
TH> If none of the following methods:
>> > getDataElement [...]
TH> are responsible for associating data array values with pixels, do
TH> you know how this association is made?
With PixelInterleavedSampleModel (it is different for different sample
models) the association is made in the constructor:
public PixelInterleavedSampleModel(int dataType, int w, int h,
int pixelStride,
int scanlineStride,
int[] bandOffsets)
The fields of interest for us are:
pixelStride, scanlineStride, and bandOffsets.
You will also probably need to make use of the DataBuffer offset
(in addition to the bandOffsets):
public DataBufferByte(byte[] dataArray, int size, int offset)
This uses the array you give it, it doesn't copy the data.
---
So let's say we wanted to select plane 15 of a 512x512x512 block, I'm
assuming 1 band data.
I'll do this for the three major axis:
Simplest case: [14][x][x]
DataBuffer.offset = 14*512*512; // select 14th slice
pixelStride = 1; // going across row order
scanlineStride = 512; // going down through the slice
bandOffsets = [0]; // Just one band here.
[x][14][x]
DataBuffer.offset = 14*512; // Start in first slice but at 14th
// line (we read across slices now).
pixelStride = 1; // We are still reading pixels in a row
scanlineStride = 512*512; // Every scan line comes from a different
// slice.
bandOffsets = [0]; // Just one band here.
[x][x][14]
DataBuffer.offset = [14]; // 14th pixel of first line of first slice.
pixelStride = 512; // We now read down a slice for pixels
scanlineStride = 512*512; // Still pull each scanline from a different
// slice.
bandOffsets = [0]; // Just one band here.
TH> I would like to find some method to override in the
TH> PixelInterleavedSampleModel, so that I can select multiple planes
TH> out of my 3D data array.
You will need to construct a new PixelInterleavedSampleModel &
DataBuffer for each plane but you won't need to copy any data.
Depending on the flexibility you need in selecting slices you may
need to go up to ComponentSampleModel (or over to BandedSampleModel,
which has a different set of constraints. It's likely that by
switching between Banded and PixelInterleaved you can cover all the
cases you need to).
In general there aren't as many optimized loops for
ComponentSampleModel but it usually doesn't need to call a method at
every pixel.
TH> By the way, before trying PixelInterleavedSampleModel, I had
TH> extended ComponentSampleModel, this was very slow, approx 30 sec
TH> to draw a 512 X 512 image. In that case, getDataElement was being
TH> called for each pixel of the image.
I am surprised to hear that it was this slow (hotspot's dynamic
inlining may help this), although in general a system that relies on a
method call per pixel will not give very good results.
--
Thomas DeWeese
[EMAIL PROTECTED]
"The only difference between theory and practice is
that in theory there isn't any." -- unknown
===========================================================================
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".