Hello everybody !

I need to display and manipulate big 2D arrays of bytes. The problem is
the order of the elements: the fastest axis is the vertical one. For
example if the array is of size n1*n2, the horizontal axis is of size
n2, the vertical one is of size n1 then the element at (x,y)  will be
x*n1 + y (x is the horizontal direction).

The question is how to create a BufferedImage from this array, without
duplicating the data and oriented the right way (so I don't have to make
any transformation when I display it).

So far I transpose the array so the fastest axis is the horizontal one
and then I use something like this to get a BufferedImage:

    //data is a byte[n2*n1] - the transposed version of the original
    WritableRaster wr = Raster
        .createInterleavedRaster( new DataBufferByte(data, data.length),
                                  n2, n1, n2, 1, new int[]{0}, null );

    //colorModel is a 256 colors IndexColorModel
    BufferedImage img = new BufferedImage(colorModel, wr, false, null);


Does anyone know how to avoid the transposition? What is the most efficient way to deal with this problem (low memory footprint and fast display). Do I have to provide a SampleModel that knows how to deal with the transposed matrix?

Thank you,
-Iulian

===========================================================================
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".

Reply via email to