question: public static WritableRaster createPackedRaster ( int dataType , int w , int h , int bands , int bitsPerBand , Point location ) { DataBuffer d ; if ( bands <= 0 ) { throw new IllegalArgumentException ( "Number of bands (" + bands + ") must be greater than 0" ) ; } if ( bitsPerBand <= 0 ) { throw new IllegalArgumentException ( "Bits per band (" + bitsPerBand + ") must be greater than 0" ) ; } if ( bands != 1 ) { int [ ] masks = new int [ bands ] ; int mask = ( 1 << bitsPerBand ) - 1 ; int shift = ( bands - 1 ) * bitsPerBand ; if ( shift + bitsPerBand > DataBuffer . getDataTypeSize ( dataType ) ) { throw new IllegalArgumentException ( "bitsPerBand(" + bitsPerBand + ") * bands is " + " greater than data type " + "size." ) ; } switch ( dataType ) { case DataBuffer . TYPE_BYTE : case DataBuffer . TYPE_USHORT : case DataBuffer . TYPE_INT : break ; default : throw new IllegalArgumentException ( "Unsupported data type " + dataType ) ; } for ( int i = 0 ; i < bands ; i ++ ) { masks [ i ] = mask << shift ; shift = shift - bitsPerBand ; } return createPackedRaster ( dataType , w , h , masks , location ) ; } else { double fw = w ; switch ( dataType ) { case DataBuffer . TYPE_BYTE : d = new DataBufferByte ( ( int ) ( Math . ceil ( fw / ( 8 / bitsPerBand ) ) ) * h ) ; break ; case DataBuffer . TYPE_USHORT : d = new DataBufferUShort ( ( int ) ( Math . ceil ( fw / ( 16 / bitsPerBand ) ) ) * h ) ; break ; case DataBuffer . TYPE_INT : d = new DataBufferInt ( ( int ) ( Math . ceil ( fw / ( 32 / bitsPerBand ) ) ) * h ) ; break ; default : throw new IllegalArgumentException ( "Unsupported data type " + dataType ) ; } return createPackedRaster ( d , w , h , bitsPerBand , location ) ; } }
target:  Creates a Raster based on a packed SampleModel with the specified data type, width, height, number of bands, and bits per band.  If the number of bands is one, the SampleModel will be a MultiPixelPackedSampleModel. <p> If the number of bands is more than one, the SampleModel will be a SinglePixelPackedSampleModel, with each band having bitsPerBand bits.  In either case, the requirements on dataType and bitsPerBand imposed by the corresponding SampleModel must be met. <p> The upper left corner of the Raster is given by the location argument.  If location is null, (0, 0) will be used. The dataType parameter should be one of the enumerated values defined in the DataBuffer class. <p> The only dataTypes supported currently are TYPE_BYTE, TYPE_USHORT, and TYPE_INT.