我下载了一组VS2015图标并阅读MSDN指南。
在“使用图像中的颜色”下,它指出:“为了使图标在Visual Studio暗主题中显示正确的对比度比率,需要通过编程应用反转。”
我试图在我的应用程序中模仿这种行为,但是当我将颜色反转应用于图像时,它不会像在VS的暗主题中看起来那样。
在“使用图像中的颜色”下,它指出:“为了使图标在Visual Studio暗主题中显示正确的对比度比率,需要通过编程应用反转。”
我试图在我的应用程序中模仿这种行为,但是当我将颜色反转应用于图像时,它不会像在VS的暗主题中看起来那样。
有人知道 VS 是如何反转颜色的,这样我就可以模仿它了吗?
编辑: 这是我正在使用的反转代码 - 问题似乎出现在具有透明度/ alpha 的边缘处:
public static void InvertColors(Bitmap bitmapImage)
{
var bitmapRead = bitmapImage.LockBits(new Rectangle(0, 0, bitmapImage.Width, bitmapImage.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppPArgb);
var bitmapLength = bitmapRead.Stride * bitmapRead.Height;
var bitmapBGRA = new byte[bitmapLength];
Marshal.Copy(bitmapRead.Scan0, bitmapBGRA, 0, bitmapLength);
bitmapImage.UnlockBits(bitmapRead);
for (int i = 0; i < bitmapLength; i += 4)
{
bitmapBGRA[i] = (byte)(255 - bitmapBGRA[i]);
bitmapBGRA[i + 1] = (byte)(255 - bitmapBGRA[i + 1]);
bitmapBGRA[i + 2] = (byte)(255 - bitmapBGRA[i + 2]);
}
var bitmapWrite = bitmapImage.LockBits(new Rectangle(0, 0, bitmapImage.Width, bitmapImage.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppPArgb);
Marshal.Copy(bitmapBGRA, 0, bitmapWrite.Scan0, bitmapLength);
bitmapImage.UnlockBits(bitmapWrite);
}