Examples of ModHuffmanOutputStream


Examples of uk.co.mmscomputing.io.ModHuffmanOutputStream

      WritableRaster   raster=image.getRaster();
      DataBufferByte   buffer=(DataBufferByte)raster.getDataBuffer();
      byte[]           imgdata=(byte[])buffer.getData();

      ByteArrayOutputStream  baos = new ByteArrayOutputStream();
      ModHuffmanOutputStream mhos;
      switch(mode){
      case compT4MH: mhos = new ModHuffmanOutputStream(baos);break;
      case compT4MR: mhos = new ModREADOutputStream(baos,width);break;
      case compT6MMR:mhos = new ModModREADOutputStream(baos,width);break;
      default: throw new IOException(cn+".writeImage: Internal Error: Unknown compression = "+mode)// Should never get here.
      }
View Full Code Here

Examples of uk.co.mmscomputing.io.ModHuffmanOutputStream

                    write to image file
        */
        ByteArrayOutputStream  baos=new ByteArrayOutputStream();
        BitSwapOutputStream    bsos=new BitSwapOutputStream(baos);
        ModHuffmanOutputStream mhos=new ModHuffmanOutputStream(bsos);

        RLEOutputStream        rlos=new RLEOutputStream(mhos,3);         // rgb = 3 bytes per sample code word (not needed here)

        for(int i=0;i<maxrps;i++){
          if((y+i)==height){break;}                                      // last strip might have less rows
View Full Code Here

Examples of uk.co.mmscomputing.io.ModHuffmanOutputStream

    WritableRaster   raster=image.getRaster();
    DataBufferByte   buffer=(DataBufferByte)raster.getDataBuffer();
    byte[]           imgdata=(byte[])buffer.getData();

    BitSwapOutputStream    bsos = new BitSwapOutputStream(baos);
    ModHuffmanOutputStream mhos = new ModModREADOutputStream(bsos,width);
    RLEBit1OutputStream    rlos = new RLEBit1OutputStream(mhos);

    int len=width>>3;                              // eight pixel per byte
    int end=8-(width&0x07);                        // how many bits of last byte represent image data

    int off=0;
    if(end==8){                                    // image row ends at byte boundary
      for(int y=0;y<height;y++){
        rlos.setStartCodeWord(0x0001);             // white run first; White is Zero: 1s in image => 0s in compressed data
        mhos.writeEOL();                           // T.6: we don't write EOL code, we just set up buffers here
        rlos.write(imgdata,off,len);
        rlos.flush();
        off+=len;
      }
    }else{
      for(int y=0;y<height;y++){
        rlos.setStartCodeWord(0x0001);             // white run first; White is Zero: 1s in image => 0s in compressed data
        mhos.writeEOL();                           // T.6: we don't write EOL code, we just set up buffers here
        rlos.write(imgdata,off,len);
        rlos.writeBits(imgdata[off+len],7,end);    // write end of line pixel
        rlos.flush();
        off+=len+1;
      }
View Full Code Here

Examples of uk.co.mmscomputing.io.ModHuffmanOutputStream

    }
  }

  private byte[] getWhiteLineCode(int width)throws IOException{
    ByteArrayOutputStream  baos=new ByteArrayOutputStream();
    ModHuffmanOutputStream mhos=new ModHuffmanOutputStream(baos);
    mhos.write(width);            
    mhos.flush();
    baos.write(0x00);baos.write(0x80); // for end of line synchronization
    mhos.close();
    return baos.toByteArray();         // 1728 white standard G3 fax line => B2 59 01 [00 80]
  }
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.