int width = image.getWidth();
// int height = image.getHeight();
BitSwapInputStream bsis = new BitSwapInputStream(data);
ModHuffmanInputStream mhis = new ModModREADInputStream(bsis,width);
RLEBitInputStream rlis = new RLEBitInputStream(mhis);
// rlis.setInvert(invert);
int off=0;
if((width&0x0007)==0){
byte[] buf=new byte[width>>3];int len=0;
while(true){
rlis.resetToStartCodeWord(); // start next line with white
mhis.readEOL(); // set settings for a new line
try{
len=rlis.read(buf); // read one image line
if(len==-1){break;} // end of page
System.arraycopy(buf,0,imgdata,off,len); // copy line to image buffer
}catch(ModHuffmanInputStream.ModHuffmanCodingException mhce){
System.out.println(getClass().getName()+".copyin:\n\t"+mhce);
}
off+=len;
}
}else{
byte[] buf=new byte[(width+7)>>3];int len=0,ecw=8-(width&0x0007),bits;
while(true){
rlis.resetToStartCodeWord(); // start next line with white
mhis.readEOL(); // set settings for a new line
try{
len=rlis.read(buf,0,buf.length-1); // read one image line
if(len==-1){break;} // end of page
bits=rlis.readBits(7,ecw);
buf[len]=(byte)bits;
System.arraycopy(buf,0,imgdata,off,len+1); // copy line to image buffer
}catch(ModHuffmanInputStream.ModHuffmanCodingException mhce){
System.out.println(getClass().getName()+".copyin:\n\t"+mhce);
}