代表PNG图像的Java类型?

发布于 2024-08-16 00:07:00 字数 44 浏览 2 评论 0原文

什么是可以保存 PNG 实现并提供对其像素缓冲区的访问的 Java 类型?

What is a Java type which can hold a PNG implement and provide access to it's pixel buffer?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

别在捏我脸啦 2024-08-23 00:07:00
BufferedImage img = ImageIO.read(new File("my.png"));
int color = img.getRGB(23,12);
BufferedImage img = ImageIO.read(new File("my.png"));
int color = img.getRGB(23,12);
也只是曾经 2024-08-23 00:07:00

我会看一下 Java Advanced Imaging,它处理多种类型的图像文件。

I would take a look at Java Advanced Imaging, it handle multiple types of image files.

旧梦荧光笔 2024-08-23 00:07:00

看一下 ImageIO 及其众多静态助手,用于读取和写入包含图像的字节/流。

Take a look ImageIO and its numerous static helpers for reading and writing bytes/streams containing an image.

最近可好 2024-08-23 00:07:00

如果您想对整个图像进行基于像素的操作,我发现每次调用 getRGB() 方法都相当慢。在这种情况下,您可能想尝试使用以下方法访问保存图像数据的实际像素数组:

byte[] pixel_array = ((DataBufferByte)img.getRaster().getDataBuffer()).getData()

可能有一种更灵活的方法,不对数组数据类型做出任何假设。

If you want to do pixel based operations on the entire image, I've found calling the getRGB() method every time to be fairly slow. In that case, you might want to try and get access to the actual pixel array holding the image data using something like:

byte[] pixel_array = ((DataBufferByte)img.getRaster().getDataBuffer()).getData()

There may be a more flexible way that doesn't make any presumptions on the array data type.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文