private void composePageSerializedGray(File outputFile) throws Exception {
  File fileSerialize=null;
  FileInputStream fis=null;
  ObjectInputStream ois=null;
  ImageData imageData=null;
  int bpr, width, height, r, g, b, row, pixel, x, i;
  byte[] data=null;
  try {
    fileSerialize=new File(path,prefix + "-serialize" + memoryBlockProcessed+ ".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();
    }
  }
  BufferedImage imageSerialized=new BufferedImage(imageData.getBpr(),memoryHeight,BufferedImage.TYPE_BYTE_GRAY);
  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();
    width=imageData.getWidth();
    height=imageData.getHeight() + memoryRow;
    bpr=imageData.getBpr();
    data=imageData.getData();
    row=0;
    pixel=0;
    while (memoryRow < height) {
      for (x=0; x < width; x++) {
        r=data[pixel] & 0x00FF;
        g=data[pixel] & 0x00FF;
        b=data[pixel] & 0x00FF;
        pixel++;
        imageSerialized.setRGB(x,memoryRow,(r << 16) | (g << 8) | b);
      }
      row+=bpr;
      pixel=row;
      memoryRow++;
    }
  }
  imageSerialized.flush();
  numPage++;
  ImageIO.write(imageSerialized,"png",outputFile);
  addTempFile(outputFile);
  addScanFile(outputFile);
}

private void composePageSerializedGray ( File outputFile ) throws Exception { File fileSerialize = null ; FileInputStream fis = null ; ObjectInputStream ois = null ; ImageData imageData = null ; int bpr , width , height , r , g , b , row , pixel , x , i ; byte [ ] data = null ; try { fileSerialize = new File ( path , prefix + "-serialize" + memoryBlockProcessed + ".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 ( ) ; } } BufferedImage imageSerialized = new BufferedImage ( imageData . getBpr ( ) , memoryHeight , BufferedImage . TYPE_BYTE_GRAY ) ; 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 ( ) ; width = imageData . getWidth ( ) ; height = imageData . getHeight ( ) + memoryRow ; bpr = imageData . getBpr ( ) ; data = imageData . getData ( ) ; row = 0 ; pixel = 0 ; while ( memoryRow < height ) { for ( x = 0 ; x < width ; x ++ ) { r = data [ pixel ] & 0x00FF ; g = data [ pixel ] & 0x00FF ; b = data [ pixel ] & 0x00FF ; pixel ++ ; imageSerialized . setRGB ( x , memoryRow , ( r << 16 ) | ( g << 8 ) | b ) ; } 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 escala de grises
