如何使用颜色色调绘制BufferedImage [英] How to draw a BufferedImage with a color tint

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

问题描述

我正在尝试使用不同的颜色色调将 BufferedImage 绘制到我的 Canvas ,但不能找到任何真正有用的例子。

I'm trying to draw a BufferedImage to my Canvas with a varying color tint, but can't find any real working examples.

我不想生成新的有色 BufferedImage ,但是反复绘制一个 BufferedImage 实时显示我的GUI,具有不同的颜色色调,具体取决于各种条件。

使用淡色调<$ c $绘制的图像c> 0xFF0000 将绘制为仅红色图像,而 0xFFFFFF 的色调不会影响图像。

I don't want to generate a new tinted BufferedImage, but repeatedly draw a BufferedImage to my GUI in real time with varying color tints, depending on various conditions.
An image drawn with a tint color of 0xFF0000 will be drawn as a red-only image, while a tint color of 0xFFFFFF won't affect the image.

如何使用我的控件的 Graphics2D 实例来完成这样的事情?

How would I accomplish such a thing using the Graphics2D instance of my control?

提前致谢。

推荐答案

也许 ColorTintFilter 来自肮脏的富客户端书籍可以帮助您。本书中的相关示例章节可在此处获取。

Maybe ColorTintFilter from Filthy Rich Clients book can help you. The relevant sample chapter from the book is available here.

以下是使用过滤器的代码段:

Here is a code snippet that uses the filter:

BufferedImage image = ...;
BufferedImageOp imageFilter = new ColorTintFilter(Color.RED, 1.0f);
image = imageFilter.filter(image, null);

这篇关于如何使用颜色色调绘制BufferedImage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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