BufferedImage颜色饱和度 [英] BufferedImage color saturation

查看:665
本文介绍了BufferedImage颜色饱和度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用



正如您所见,PDF图像更苍白(饱和度? - 抱歉,我不是很好在色彩理论上,不知道如何正确命名。)



我发现了什么:


  1. 使用JLabel(新的ImageIcon(bimg))将BufferedImage打印到JLabel
    构造函数产生与PDF相同的结果(苍白颜色)
    所以我猜PDFBox不是原因。

  2. 更改扫描分辨率 -
    无效。

  3. bimg.getTransparency()返回1(OPAQUE)

  4. bimg.getType()返回0(TYPE_CUSTOM)

PNG文件:



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



PDF文件



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

解决方案

JFreeSane中存在颜色空间问题,它在版本0.97中得到修复:



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


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

Here is the scanning 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 making 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:

As you can see the PDF image is more "pale" (saturation? - sorry, I'm not good at color theory and don't know how to name it correctly).

What I have found out:

  1. Printing BufferedImage to JLabel using JLabel(new ImageIcon(bimg)) constructor produces the same result as with PDF ("pale" colors) so I guess PDFBox is not the reason.
  2. Changing scanning resolution - no effect.
  3. bimg.getTransparency() returns 1 (OPAQUE)
  4. 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

解决方案

There was an issue in JFreeSane with colorspaces, it was fixed in version 0.97:

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

这篇关于BufferedImage颜色饱和度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆