Hello,
I'm trying to create a BufferedImage from a 2D int array as follows:
====================================================
int width = 256;
int height = 256;
int [ ][ ] myData = new int[width][height];
/*
load values into myData
*/
rgbImage = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);
WritableRaster wr = rgbImage.getRaster( );
DataBuffer db = new DataBufferInt(myData, myData.length);
wr.setDataElements(width, height, db);
====================================================
the last line throws an exception:
java.lang.ClassCastException: java.awt.image.DataBufferInt
at
sun.awt.image.IntegerInterleavedRaster.setDataElements(IntegerInterleavedRas
ter.java:269)
Can some one help me? How do I feed a 2D int array to a BufferedImage?
Ted Hill
Software Engineer
Tomotherapy
[EMAIL PROTECTED]
===========================================================================
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".