BufferedImage的getSubimage性能

发布于 2024-07-13 05:00:39 字数 348 浏览 3 评论 0原文

我正在开发一个 Java 2D 渲染程序(在 1.6.0_11 上运行),它使用外部图像进行 UI 渲染。 这些大图像同时包含多个 UI 图形部分,我现在使用 BufferedImage.getSubimage() 提取它们。 假设一个普通的桌面系统(没有启用 DirectX/OpenGL 加速),我的问题是:

  • getSubimage() 是一个内存高效的调用,因为它共享底层图像数据,但这是否会影响这些子图像的渲染速度Graphics2D.drawImage()?
  • 如果图像使用每像素 8 位调色板模式,那么使用 RGBA 模式(例如 4 倍内存)或依赖调色板颜色模型(例如转换时间)的增益/损失是多少?

I'm working on a Java 2D rendering program (running on 1.6.0_11), which uses external images for its UI rendering. These large images contain several UI graphics parts at the same time, which I extract now with the BufferedImage.getSubimage(). Assuming an average desktop system (with our without enabling DirectX/OpenGL acceleration), my questions are:

  • The getSubimage() is a memory efficient call, as it shares the underlying image data, but does this affect the rendering speed of these sub images with the Graphics2D.drawImage()?
  • If the images use 8 bit per pixel color palette mode, what would be the gain/loss of using RGBA mode (e.g. 4x memory) or relying on the palette color model (e.g conversion time)?

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

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

发布评论

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

评论(1

太阳哥哥 2024-07-20 05:00:39

据我所知, getSubimage(...) 不应该对渲染产生任何重大影响。

转换图像数据的速度很慢,通常最好尽量避免即时进行转换。


对于图像来说,慢速可以分为两类:

  • 磁盘 I/O
  • 数据处理

磁盘 I/O 很容易成为最慢的部分。

如果您打算仅使用图像的一部分,那么最好能够仅从磁盘加载图像的一部分。

我的经验是 JAI 更擅长只做真正的事情比标准库的东西更需要。

As far as I know, getSubimage(...) shouldn't have any significant effect to the rendering.

Converting image data is slow and usually it is better to try to avoid doing it on the fly.


With images slowness can be divided to two categories:

  • Disk I/O
  • Data processing

And disk I/O can easily be the slowest part.

If you are going to use only part of the image, it would be best to be able to load only part of the image from disk.

My experience is that JAI is better at doing only what is really needed than the standard library stuff.

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