BufferedImage color saturation

I am writing a simple scanning application using jfreesane and Apache PDFBox .

Here is the scan code:

InetAddress address = InetAddress.getByName("192.168.0.17"); SaneSession session = SaneSession.withRemoteSane(address); List<SaneDevice> devices = session.listDevices(); SaneDevice device = devices.get(0); device.open(); device.getOption("resolution").setIntegerValue(300); BufferedImage bimg = device.acquireImage(); File file = new File("test_scan.png"); ImageIO.write(bimg, "png", file); device.close(); 

And creating a PDF:

 PDDocument document = new PDDocument(); float width = bimg.getWidth(); float height = bimg.getHeight(); PDPage page = new PDPage(new PDRectangle(width, height)); document.addPage(page); PDImageXObject pdimg = LosslessFactory.createFromImage(document, bimg); PDPageContentStream stream = new PDPageContentStream(document, page, PDPageContentStream.AppendMode.APPEND, true); stream.drawImage(pdimg, 0, 0); stream.close(); document.save(filename); document.close(); 

And here is the result:

enter image description here

As you can see, the PDF image is more โ€œpaleโ€ (saturation? - Sorry, I am not good at color theory and donโ€™t know how to name it correctly).

What I learned:

  • Printing a BufferedImage in JLabel using the JLabel (new ImageIcon (bimg)) constructor gives the same result as in the PDF format (โ€œfadedโ€ colors) so I think the PDFBox is not the reason.
  • Changing scan resolution - no effect.
  • bimg.getTransparency () returns 1 (OPAQUE)
  • bimg.getType () returns 0 (TYPE_CUSTOM)

PNG file:

http://s000.tinyupload.com/index.php?file_id=95648202713651192395

Pdf file

http://s000.tinyupload.com/index.php?file_id=90369236997064329368

+6
source share
1 answer

JFreeSane had a problem with color spaces, it was fixed in version 0.97:

https://github.com/sjamesr/jfreesane/releases/tag/jfreesane-0.97

+1
source

All Articles