gpt4 book ai didi

c# - VS2015图标指南-颜色反转

转载 作者:太空狗 更新时间:2023-10-29 23:06:00 29 4
gpt4 key购买 nike

我下载了一组 VS2015 图标并阅读了 MSDN guide

在“在图像中使用颜色”下,声明“为了使图标在 Visual Studio 深色主题中以正确的对比度显示,以编程方式应用反转。” p>

我试图在我的应用程序中模仿这种行为,但是当我对图像应用颜色反转时,它并没有像在 VS 的深色主题中那样显示:

enter image description here

有谁知道 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);
}

最佳答案

您可以使用 IVsUIShell5.ThemeDIBits应用就地反演的方法。还有ThemedImageSourceConverter用于创建倒置图像的 WPF 帮助器类。

关于c# - VS2015图标指南-颜色反转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36778989/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com