如何使用 GDI+ 的 ImageAttributes
(可能还有 ColorMatrix
)旋转图像的色调?
请注意,我想旋转色调,而不是给图像着色。
编辑:通过旋转色调,我的意思是图像中的每种颜色都应该转变为不同的颜色,而不是使整个图像成为一种颜色的阴影。
例如,
原文:http://www.codeguru.com/img/legacy/gdi/Tinter03.jpg
旋转:http://www.codeguru.com/img/legacy/gdi/Tinter15.jpg或 http://www.codeguru.com/img/legacy/gdi/Tinter17.jpg
最佳答案
I threw this together对于这个问题(帖子底部链接的带有 c# 项目的 ZIP 文件)。它不使用 ImageAttributes
或 ColorMatrix
,但它会按照您所描述的那样旋转色调:
//rotate hue for a pixel
private Color CalculateHueChange(Color oldColor, float hue)
{
HLSRGB color = new HLSRGB(
Convert.ToByte(oldColor.R),
Convert.ToByte(oldColor.G),
Convert.ToByte(oldColor.B));
float startHue = color.Hue;
color.Hue = startHue + hue;
return color.Color;
}
关于c# - 在 C# 中使用 ImageAttributes 旋转色调,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1079820/