从 PNG 或 GIF 图像中屏蔽白色,使用任何颜色将其传输到画布
源是 PNG 或 GIF,其中应“着色”的像素为白色。背景可以是黑色或透明,以最简单的为准。
现在我想剪下源的矩形部分,并将其与“画笔”的调色板颜色(gif)或RGB颜色(png)相结合,以将其“标记”在TImage/TCanvas上颜色。
可能是 RTFM 会做的那些懒惰问题之一。但如果你有一个好的解决方案,请分享:)
我尝试了 Daud 的 PNGImage 库,但我什至无法让它加载源图像。使用起来有什么技巧吗?
该解决方案需要在 D7 及更高版本、XP 及更高版本上运行。
Source is either PNG or GIF where the pixels that should be "colorized" are white. Background can be either black or transparent, whichever is easiest.
Now I'd like to cut out a rectangular part of the source, and AND it with the palette color (gif) or RGB color (png) of the "brush", to "stamp" it out on a TImage/TCanvas with that color.
Probably one of those lazy questions where RTFM would do. But if you have a nice solution please share :)
I tried Daud's PNGImage lib, but I can't even get it loading the source image. Is there a trick to using it?
The solution needs to work on D7 and up, XP and up.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我明白你想用其他颜色改变白色吗?
如果是这样,我认为你应该逐像素检查图像并检查像素是什么颜色,如果是白色则更改它。
这就是循环浏览图像的方法。
下面的代码演示了如何读取红色和蓝色值并切换它们。
但这仅适用于位图图像。
如果这有用,请尝试将图像转换为位图,然后对其进行操作。
do i understand you want to change the white color with some other color?
if that is so i think you should check the image pixel by pixel and check what color is the pixel and change it if is white.
thats how you can loop through image
Here's code that show how to reads the Red and Blue values and switched them.
but this is for bitmap image only.
if this is useful try to convert your image to bitmap and from then manipulate it.