我正在使用jfreesane和Apache PDFBox编写简单的扫描应用程序。
以下是扫描码:
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();
制作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();
结果如下:
正如您所看到的,PDF图像更加“苍白”。 (饱和度? - 抱歉,我不擅长色彩理论,也不知道如何正确命名。)
我发现了什么:
PNG文件:
http://s000.tinyupload.com/index.php?file_id=95648202713651192395
PDF文件
http://s000.tinyupload.com/index.php?file_id=90369236997064329368
答案 0 :(得分:1)
JFreeSane中存在颜色空间的问题,它在版本0.97中得到修复:
https://github.com/sjamesr/jfreesane/releases/tag/jfreesane-0.97