levigo / jbig2-imageio

A Java ImageIO plugin for the JBIG2 bi-level image format
Apache License 2.0
31 stars 19 forks source link

Trying to copy a non-existing line in generic region decoding #1

Closed ghost closed 9 years ago

ghost commented 10 years ago

If the typical prediction feature is enabled (TPGDON is 1) and LTP is set to 1 the algorithm defined in ITU-T Rec. T.88, 6.2.5.7 Decoding the bitmap describes that the current row should receive all pixels of the row immediately above. That won't work if the current row is the first (top) row of the page.

vishwas1384 commented 9 years ago

Hi,

I am trying to decode a jbig2 file to a png file. But the code is slower especially while reading the image. Could you suggest me performance improvements so that execution is faster.Currently it takes 485ms.I want it to be reduced to under 150ms. I am posting the code that I use to decode.

Iterator<?> readers = ImageIO.getImageReadersByFormatName("JBIG2"); //takes about 80ms

ImageReader reader = (ImageReader) readers.next(); Object source = fis; //reading the jbig2 file from the disk using FileInputStream fis ImageInputStream iis = ImageIO.createImageInputStream(source); reader.setInput(iis, true); ImageReadParam param = reader.getDefaultReadParam();

Image image = reader.read(0, param); // takes about 150ms

BufferedImage bufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_BYTE_BINARY);

Graphics2D g2 = bufferedImage.createGraphics(); g2.drawImage(image, null, null);

Eagerly waiting for your reply. Thank You

ghost commented 9 years ago

Please open a new issue as this has nothing to do with the existing.