【问题标题】:Changing the color of a BufferedImage更改 BufferedImage 的颜色
【发布时间】:2012-03-21 23:12:46
【问题描述】:

大家好,我正在计算分形并根据完成的迭代次数绘制缓冲图像。为了简单起见,让我以这种方式使用 completedIterations 为 bufferdImage 着色:

g.setColor(Color.getHSBColor((float) (colorValue - completedIterations), 1F, 1F));

在生成图像时 colourValue 是恒定的,假设在这种情况下它是 0.2。

我在 JPanel 上有一个滑块,当使用它时,它会在 0 到 1 的范围内更改颜色值。 当 colorValue 改变时,我想实时更新 BufferedImage,但我不想重新计算所有图像点,因为这会导致大量开销 - 我只想根据新的 colorValue 重新着色 BufferedImage。

这可以做到吗?如果可以,我将如何实施?

亲切的问候

格雷格

【问题讨论】:

    标签: java bufferedimage


    【解决方案1】:

    您可以使用setRGB()设置单个像素,如图here;或者使用RescaleOp调整多个像素,如图here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-25
      • 1970-01-01
      • 2012-11-02
      • 1970-01-01
      相关资源
      最近更新 更多