【问题标题】:Java paint speed relative to color modelJava 绘制速度相对于颜色模型
【发布时间】:2010-03-26 22:47:17
【问题描述】:

我有一个带有 IndexColorModel 的 BufferedImage。我需要将该图像绘制到屏幕上,但我注意到使用 IndexColorModel 时这很慢。但是,如果我通过身份仿射变换运行 BufferedImage,它会创建一个带有 DirectColorModel 的图像,并且绘画速度要快得多。这是我正在使用的代码

AffineTransformOp identityOp = new AffineTransformOp(new AffineTransform(), AffineTransformOp.TYPE_BILINEAR);
displayImage = identityOp.filter(displayImage, null);

我有三个问题
1. 为什么在 IndexColorModel 上绘制速度较慢?
2、有什么办法可以加快IndexColorModel的绘制速度?
3. 如果 2. 的答案是否定的,这是从 IndexColorModel 转换为 DirectColorModel 的最有效方法吗?我注意到这种转换取决于图像的大小,我想删除这种依赖关系。

感谢您的帮助

【问题讨论】:

  • 你是如何创建 BufferedImage 的?
  • 我正在使用 1.4 版通过 dcm4che 创建它。这是一个非常复杂的项目。您想了解哪些具体信息?

标签: java paint bufferedimage


【解决方案1】:

评论太长了...

您确定您正在创建的 BufferedImage 是最好的,具体取决于您所使用的操作系统?您应该始终创建一个“兼容的”BufferedImage。例如,Windows 上最快的可能是TYPE_INT_ARGB,但在 OS X 上不是这样,反之亦然。

类似这样的东西(哎哟,得墨忒耳法则很痛;):

GraphicsEnvironment
        .getLocalGraphicsEnvironment()
        .getDefaultScreenDevice()
        .getDefaultConfiguration()
        .createCompatibleImage(width, height,Transparency.TRANSLUCENT)

【讨论】:

  • 我无法控制初始 ColorModel。我必须调用一个返回给我 IndexColorModel 的函数。然后我调用 displayImage = new BufferedImage(cm, displayImage.getRaster(), false, null) 其中 cm 是 IndexColorModel。有没有更好的方法来集成这个 IndexColorModel?
猜你喜欢
  • 2021-03-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-03-19
  • 1970-01-01
  • 2012-01-31
相关资源
最近更新 更多