Java:如何以编程方式为该PNG着色? [英] Java : How to tint this PNG programmatically?

查看:98
本文介绍了Java:如何以编程方式为该PNG着色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个国际象棋小程序的框架内,我有几套这样的灰度/黑色和黑色.白色(不确定):

Within the frame of a chess applet, I have a few sets of such greyscale/black & white (not sure) :

是否可以通过Java代码为PNG图片赋予颜色色彩?试图用谷歌搜索此事,但没有找到与我要找的东西真正匹配的东西.

Is there any way to give a color tint to a PNG picture via Java Code ? Tried to google the matter and didn't find anything really matching what I'm looking for.

例如,对于以下作品,我想为White播放器赋予白色/黄色调,为Black播放器赋予黑色的风味.动态设置颜色的想法是在运行时调整主题.

For the following piece for example, I'd like to give it white/yellow tint for the White player, and a flavour of black for the Black player. The idea of setting the color dynamically is to tweak themes at runtime.

推荐答案

为您的程序提供半透明图像(PNG)更为简单,这些图像可以是所需颜色的纯色(纯色或渐变色),一定百分比的透明度(您可以在1分钟内在photoshop/illustrator中完成此操作).

It would be a lot simpler to give your program translucent images (PNG) which are plain coloured (plain or gradient) in the colours you want, and have a certain % of transparency (you can do that in photoshop/illustrator in 1min).

然后以编程方式将着色图像(保持透明度)与下面的其他图像合并.

Then programmatically merge the tint image (preserving transparency) with the other image underneath.

检查此SO帖子,了解如何合并两个图像: 合并两个图像

Check this SO post for how to merge two images: Merging two images

这篇关于Java:如何以编程方式为该PNG着色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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