> I send myself the answer since I have found the bug. I apologize but hope
> it could be useful for others.
> Obviously the argument "int[] bandMasks" of
> "Writable.Raster.createPackedRaster" is not shifts but masks (shame on
> me).
> So instead of writing
> WritableRaster raster = Raster.createPackedRaster(dataBuffer, bmWidth,
> bmHeight, bmWidth,
>
> new int[] {16, 8, 0, 24}, null);
>
> I have to write
> int[] masks = new int[] {0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000};
> WritableRaster raster = Raster.createPackedRaster(dataBuffer, bmWidth,
> bmHeight, bmWidth,
>
> masks, null);
>
> Cheers
> Paul
>
> -----Original Message-----
> From: Kerbiriou Paul [SMTP:[EMAIL PROTECTED]]
> Sent: Friday, October 01, 1999 9:37 AM
> To: [EMAIL PROTECTED]
> Subject: [JAVA2D] IntegerInterleavedRaster incompatible with
> DirectColorModel
>
> Hi,
> I have the same problem as Renaud (see the mails below) , that is to
> avoid
> copying data to a BufferedImage but rather passing to it an already
> existing
> int array that is animated.
> I have read the Jeannette's answer and written the following method.
>
> /**
> This function creates the BufferedImage from the so called bitmap.
> */
> protected void updateImage() {
> // get the image data
> int[] bm = m_bitmap.getPixels(); // array
> of
> 0xAARRGGBB pixels
> int bmWidth = m_bitmap.getWidth(); // width of the image
> int bmHeight = m_bitmap.getHeight(); // height of the
> image
>
> // build the Raster and the ColorModel
> DataBufferInt dataBuffer = new DataBufferInt(bm,
> bmWidth * bmHeight);
> WritableRaster raster =
> Raster.createPackedRaster(dataBuffer, bmWidth, bmHeight, bmWidth,
>
> new
> int[] {16, 8, 0, 24}, null);
> DirectColorModel colorModel = new DirectColorModel(32,
> 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
>
> // create the BufferedImage
> m_image = new BufferedImage(colorModel, raster, false, null);
> }
>
> Unfortunately, it doesn't work. Particularly I do not understand why after
> creating a "Raster based on a SinglePixelPackedSampleModel" I got an
> exception saying "Raster IntegerInterleavedRaster" is incompatible with a
> DirectColorModel.
>
> Exception occurred during event dispatching:
> java.lang.IllegalArgumentException: Raster IntegerInterleavedRaster: width
> =
> 176 height = 144 #Bands = 4
> #DataElements 1 xOff = 0 yOff = 0 dataOffset[0] 0 is incompatible with
> ColorModel DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff
> amask=ff000000
> at mpw.renderer.AnimatedBitmap.updateImage(Compiled Code)
> at mpw.renderer.AnimatedBitmap.render(Texture.java:212)
>
>
> Thank you in advance
>
> Paul
>
>
>
> > -----Original Message-----
> > From: Jeannette Hung [SMTP:[EMAIL PROTECTED]]
> > Sent: Tuesday, September 28, 1999 12:56 AM
> > To: [EMAIL PROTECTED]
> > Subject: Re: [JAVA2D] Fast data copy
> >
> > Hi Renaud,
> > If you know what you are doing, you can construct a DataBuffer with
> > the array. For instance,
> > new DataBufferInt(yourData, yourDataSize)
> > Then you can create a Raster that uses the DataBuffer and a ColorModel
> > to create a BufferedImage.
> >
> > jeannette
> >
> > > MIME-Version: 1.0
> > > Date: Tue, 28 Sep 1999 00:32:23 +0200
> > > From: CAZOULAT Renaud CNET/DIH/REN
> > <[EMAIL PROTECTED]>
> > > Subject: [JAVA2D] Fast data copy
> > > To: [EMAIL PROTECTED]
> > >
> > > Hi,
> > >
> > > Does someone know if there is a mean to set new data in a buffer
> > *without*
> > > data
> > > copying ? (i.e. by reference).
> > > The BufferedImage.setRGB as well as the
> > BufferedImage.getRaster().setPixels
> > > seems
> > > to copy the data even if the colormodel and the data types are the
> same.
> > >
> > > renaud cazoulat
> > >
> > >
> >
> ==========================================================================
> > =
> > > 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 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 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 JAVA2D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".