GD 颜色替换
这真是要了我的命。
图像的背景是纯红色,前景是纯灰色。前景边缘有一些从灰色到白色的抗锯齿效果。
我需要做的是将前景色更改为用户指定的颜色,并将红色更改为透明。使用 imagecolorcloset + imagecolorset/imagecolortransparent 这很容易。问题出在抗锯齿部分。
我相信我需要循环遍历图像中的像素。这似乎有效: http://www.php.net/manual /en/book.image.php#98153
我相信我现在需要确定前景色和抗锯齿颜色之间的色差。
所以...
前景色 = rgb (153, 153, 153)
抗锯齿像素 = rgb (173, 173, 173)
新颜色 = rgb (0, 0, 255)
如何确定颜色差异AA 像素和前景色之间,然后将其应用到新颜色?
This is killing me..
The Image has a background of solid red, a foreground of solid grey. On the edges of the foreground there is some anti-aliasing from grey to white.
What I need to do is change the foreground color to a user specified color and the red to transparent. This is easy enough using imagecolorcloset + imagecolorset/imagecolortransparent. The problem is the antialasing part.
I believe I need to loop through the pixels in the image. This would appear to work: http://www.php.net/manual/en/book.image.php#98153
I believe that I now need to determine the color difference between the foreground color and the anti aliased color.
So...
Foreground Color = rgb (153, 153, 153)
Anti-Alias Pixel = rgb (173, 173, 173)
New Color = rgb (0, 0, 255)
How do I determine the difference in color between the AA Pixel and the Foreground Color then apply it to the new color?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
编辑:原来这与因素有关
抗锯齿值应该是相同的因素,所以
Edit: Turns out it's to do with factors
The anti-alias value should be the same factor so