>
>I have an array of shorts[] data = {10,2,37,4 ... 44}
>I theres 20 rows 9 columns in the array, and i want to interpret the data as
>UShort pixelvalues, by creating a DataBufferUShort from the data.
>
>how do I go further from here? how do i create a SampleModel how do I create a
>WriteableRaster and soforth, so that in the end i can operate on a
BufferedImage.
>
>So for short: how do I create a BufferedImage having only an array of numbers?
>
>Ole
Hi Ole:
There are several ways to do this, but a simple one for your case
would be as follows.
int width = 9;
int height = 20;
// Create an empty BufferedImage
BufferedImage bi = new BufferedImage(width, height,
BufferedImage.TYPE_USHORT_GRAY);
// Get the DataBuffer
DataBufferUShort db = (DataBufferUShort)bi.getRaster().getDataBuffer();
// Copy your data into the DataBuffer's data array
System.arraycopy(data, 0, db.getData(), 0, width*height);
Regards,
Link Perry
===========================================================================
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".