TJF*_*TJF 5 c# visual-studio visual-studio-2015
我下载了一组VS2015图标并通过MSDN指南阅读
在"使用图像中的颜色"下,声明" 为了使图标在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);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
577 次 |
| 最近记录: |