Examples of ModHuffmanInputStream


Examples of uk.co.mmscomputing.io.ModHuffmanInputStream

        in.seek(offsets[i]);
        byte[] data=new byte[(int)counts[i]];
        in.read(data);

        ByteArrayInputStream  bais=new ByteArrayInputStream(data);
        ModHuffmanInputStream mhis;
        if(ifd.getFillOrder()==LowColHighBit){              // baseline tiff default
          mhis=getDecoder(new BitSwapInputStream(bais),ifd);
        }else{                                              // fax devices usually code low pixel col low bit positions
          mhis=getDecoder(bais,ifd);
        }
View Full Code Here

Examples of uk.co.mmscomputing.io.ModHuffmanInputStream

      System.out.println(((t4o&0x00000001)==0)?"1-dim (MH)":"2-dim (MR)");
      System.out.println(((t4o&0x00000002)==0)?"Compressed":"Uncompressed mode (not allowed in rfc 2306)");
      System.out.println(((t4o&0x00000004)==0)?"non-byte-aligned":"byte-aligned");
*/
      if((t4o&0x00000001)==0){
        return new ModHuffmanInputStream(is);
      }else{
        return new ModREADInputStream(is,ifd.getWidth());
      }
    case CCITTFAXT6:
      int t6o=ifd.getT6Options();                       // Assume: T6Options == 0 => compressed MMR coding
View Full Code Here

Examples of uk.co.mmscomputing.io.ModHuffmanInputStream

    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;
View Full Code Here

Examples of uk.co.mmscomputing.io.ModHuffmanInputStream

    }
    return image;
  }

  static private int readMH(byte[] imgdata,int off,InputStream is,int width)throws IOException{
    ModHuffmanInputStream mhis=new ModHuffmanInputStream(is);
    RLEBitInputStream     rlis=new RLEBitInputStream(mhis);

    if((width&0x0007)==0){
      byte[] buf=new byte[width>>3];int len=0;
      while(true){
        rlis.resetToStartCodeWord();                    // start next line with white
        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
          mhis.skipPadding(8);                          // skip bits up until next byte boundary
        }catch(ModHuffmanInputStream.ModHuffmanCodingException mhce){
          System.out.println(cn+".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
        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
          mhis.skipPadding(8);                          // skip bits up until next byte boundary
        }catch(ModHuffmanInputStream.ModHuffmanCodingException mhce){
          System.out.println(cn+".copyin:\n\t"+mhce);
        }
        off+=len+1;
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.