If you have the bands in seperate elements of the DataBuffer then you have to use a ComponentColorModel.
pujita pinnamaneni schrieb: > Hi all, > I am trying to create a buffered image in the > following way....I am getting the exception, I have > shown below. Could anyone suggest the correction > necessary? or any other way to create a buffered > Image? > > cs = ColorSpace.getInstance(ColorSpace.CS_sRGB); > DirectColorModel dcm = new DirectColorModel(cs, 24, > 0xff0000, 0x00ff00, 0x0000ff, 0x0, false, > DataBuffer.TYPE_BYTE); > DataBuffer db = new DataBufferByte(readData(), > texturewidth * textureheight * 3); > > int[] band = new int[]{0,1,2}; > raster = WritableRaster.createInterleavedRaster(db, > texturewidth, textureheight, texturewidth * 3, 3, > band, null); > img = new BufferedImage(dcm, raster, true, null); > > Exception in thread "main" > java.lang.IllegalArgumentException: Raster > ByteInterleavedRaster: width = 128 height = 128 > #numDataElements 3 dataOff[0] = 0 is incompatible with > ColorModel DirectColorModel: rmask=ff0000 gmask=ff00 > bmask=ff amask=0 > at > java.awt.image.BufferedImage.<init>(BufferedImage.java:517) > > Thanks, > Pujita. > > __________________________________________________ > Do You Yahoo!? > Yahoo! Tax Center - online filing with TurboTax > http://taxes.yahoo.com/ > > =========================================================================== > 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". =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".