I am trying to create an RGB image with 3 bits per spot. Each plane of data is stored 
in a byte array.
(Note that the r,g,and b arrays are perturbed from a standars RGB setup )



          nativeDataBuffer is a 3 by TOTAL_BYTES array with

nativeDataBuffer[0] = Red plane data
nativeDataBuffer[0] = Green plane data
nativeDataBuffer[0] = Blue plane data

where each plane contains 1 bit per spot data packed into bytes.


          int [] bankIndices = { 0, 1, 2 } ;
          int [] bandOffsets = { 0, 0, 0 } ;

         ComponentSampleModel bsm = new ComponentSampleModel(
                                 DataBuffer.TYPE_BYTE,
                                 imageWidth,imageLength,
                                 0, imageLength, bankIndices, bandOffsets ) ;

          WritableRaster rast = Raster.createWritableRaster(
     bsm, new DataBufferByte( nativeDataBuffer, totalBytes ), new Point() ) ;


          byte[] r = new byte[8] ;
          byte[] g = new byte[8] ;
          byte[] b = new byte[8] ;

          r[0] = (byte)0x00 ;
          r[1] = (byte)0x00 ;
          r[2] = (byte)0x00 ;
          r[3] = (byte)0x00 ;
          r[4] = (byte)0xff ;
          r[5] = (byte)0x00 ;
          r[6] = (byte)0x00 ;
          r[7] = (byte)0x00 ;
          g[0] = (byte)0x00 ;
          g[1] = (byte)0x00 ;
          g[2] = (byte)0x00 ;
          g[3] = (byte)0x00 ;
          g[4] = (byte)0x00 ;
          g[5] = (byte)0x00 ;
          g[6] = (byte)0x00 ;
          g[7] = (byte)0x00 ;
          b[0] = (byte)0x00 ;
          b[1] = (byte)0x00 ;
          b[2] = (byte)0x00 ;
          b[3] = (byte)0x00 ;
          b[4] = (byte)0x00 ;
          b[5] = (byte)0x00 ;
          b[6] = (byte)0xff ;
          b[7] = (byte)0x00 ;

          IndexColorModel cm = new IndexColorModel( 3, 8, r, g, b ) ;

          ColorSpace cs = ColorSpace.getInstance( ColorSpace.CS_sRGB ) ;
          ColorModel cm2 = new ComponentColorModel(cs,
                                 new int[] { 1, 1, 1 } ,
                                 false, false,
                                 Transparency.OPAQUE,
                                 DataBuffer.TYPE_BYTE ) ;

          outImg = new BufferedImage( cm, rast, false, null ) ;


//////////////////////////////////////////  END OF CODE

The problem is that I keep getting an

 Illegal Argument Exception: Raster java.awt.iamge.WritableRaster@ab3da3e is 
incompatible with
ColorModel IndexCOlorModel: #pixelBits = 3 numComponents = 3 color space = 
java.awt.color.ICC_ColorSpace@54561a3c transparency
= -1 has alpha = false isAlphaPre = false

I have tried many variants, none of which seem to work ( similar errors) . What am I 
doing wrong?

Thanks!

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