private void composePageSerializedBw(File outputFile) throws Exception {
  File fileSerialize=null;
  FileInputStream fis=null;
  ObjectInputStream ois=null;
  ImageData imageData=null;
  int bpr, height, bit, i, row, pixel, x, bytePixel=0;
  byte[] data;
  int[] bits=null;
  try {
    fileSerialize=new File(path,prefix + "-serialize" + memoryBlockProcessed+ ".data");
    fis=new FileInputStream(fileSerialize);
    ois=new ObjectInputStream(fis);
    imageData=(ImageData)ois.readObject();
  }
 catch (  Exception e) {
    throw e;
  }
 finally {
    if (ois != null) {
      ois.close();
    }
    if (fis != null) {
      fis.close();
    }
  }
  BufferedImage imageSerialized=new BufferedImage(imageData.getBpr() * 8,memoryHeight,BufferedImage.TYPE_INT_RGB);
  for (i=memoryBlockProcessed; i < memoryBlockTotal; i++) {
    try {
      fileSerialize=new File(path,prefix + "-serialize" + i+ ".data");
      fis=new FileInputStream(fileSerialize);
      ois=new ObjectInputStream(fis);
      imageData=(ImageData)ois.readObject();
      ois.close();
      fis.close();
    }
 catch (    Exception e) {
      throw e;
    }
 finally {
      if (ois != null) {
        ois.close();
      }
      if (fis != null) {
        fis.close();
      }
    }
    fileSerialize.delete();
    height=imageData.getHeight() + memoryRow;
    bpr=imageData.getBpr();
    data=imageData.getData();
    row=0;
    pixel=0;
    while (memoryRow < height) {
      for (x=0; x < bpr; x++) {
        bytePixel=data[pixel] & 0x00FF;
        bits=getReverseBitsFromByte(bytePixel);
        for (bit=0; bit < 8; bit++) {
          imageSerialized.setRGB((x * 8) + bit,memoryRow,(bits[bit] == 0) ? 0 : 0xFFFFFF);
        }
        pixel++;
      }
      row+=bpr;
      pixel=row;
      memoryRow++;
    }
  }
  imageSerialized.flush();
  numPage++;
  ImageIO.write(imageSerialized,"png",outputFile);
  addTempFile(outputFile);
  addScanFile(outputFile);
}

private void composePageSerializedBw ( File outputFile ) throws Exception { File fileSerialize = null ; FileInputStream fis = null ; ObjectInputStream ois = null ; ImageData imageData = null ; int bpr , height , bit , i , row , pixel , x , bytePixel = 0 ; byte [ ] data ; int [ ] bits = null ; try { fileSerialize = new File ( path , prefix + "-serialize" + memoryBlockProcessed + ".data" ) ; fis = new FileInputStream ( fileSerialize ) ; ois = new ObjectInputStream ( fis ) ; imageData = ( ImageData ) ois . readObject ( ) ; } catch ( Exception e ) { throw e ; } finally { if ( ois != null ) { ois . close ( ) ; } if ( fis != null ) { fis . close ( ) ; } } BufferedImage imageSerialized = new BufferedImage ( imageData . getBpr ( ) * 8 , memoryHeight , BufferedImage . TYPE_INT_RGB ) ; for ( i = memoryBlockProcessed ; i < memoryBlockTotal ; i ++ ) { try { fileSerialize = new File ( path , prefix + "-serialize" + i + ".data" ) ; fis = new FileInputStream ( fileSerialize ) ; ois = new ObjectInputStream ( fis ) ; imageData = ( ImageData ) ois . readObject ( ) ; ois . close ( ) ; fis . close ( ) ; } catch ( Exception e ) { throw e ; } finally { if ( ois != null ) { ois . close ( ) ; } if ( fis != null ) { fis . close ( ) ; } } fileSerialize . delete ( ) ; height = imageData . getHeight ( ) + memoryRow ; bpr = imageData . getBpr ( ) ; data = imageData . getData ( ) ; row = 0 ; pixel = 0 ; while ( memoryRow < height ) { for ( x = 0 ; x < bpr ; x ++ ) { bytePixel = data [ pixel ] & 0x00FF ; bits = getReverseBitsFromByte ( bytePixel ) ; for ( bit = 0 ; bit < 8 ; bit ++ ) { imageSerialized . setRGB ( ( x * 8 ) + bit , memoryRow , ( bits [ bit ] == 0 ) ? 0 : 0xFFFFFF ) ; } pixel ++ ; } row += bpr ; pixel = row ; memoryRow ++ ; } } imageSerialized . flush ( ) ; numPage ++ ; ImageIO . write ( imageSerialized , "png" , outputFile ) ; addTempFile ( outputFile ) ; addScanFile ( outputFile ) ; }
permite componer los diversos ficheros serializados correspondientes a cada bloque de memoria y genera un png para la pagina completa para escaneos en blanco y negro
