VS2015 icon guide - color inversion

I downloaded the VS2015 icon set and read the MSDN manual

The section "Using color in images" states that "Inversion is applied programmatically to make icons with the correct contrast in a dark Visual Studio theme."

I am trying to reproduce this behavior in my application, but when I apply color inversion to the image, it does not look like it looks in the dark VS theme:

enter image description here

Does anyone know exactly how VS inverts colors, so I can simulate this?

EDIT: This is the inversion code I'm using - the problem is that the edges have transparency / 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);
    }
+4
source share
2

, IVsUIShell5.ThemeDIBits:

, "" . . "" .

, HSL, . -:

    private double TransformLuminosity(double luminosity)
    {
        double haloLuminosity = HaloLuminosity; //Color.FromArgb(255, 246, 246, 246)
        double themeBackgroundLuminosity = ThemeBackgroundColor.L;

        if (themeBackgroundLuminosity < LuminosityInversionThreshold) //LuminosityInversionThreshold = 0.5
        {
            haloLuminosity = 1.0 - haloLuminosity;
            luminosity = 1.0 - luminosity;
        }

        if (luminosity < haloLuminosity)
        {
            return themeBackgroundLuminosity * luminosity / haloLuminosity;
        }

        return (1.0 - themeBackgroundLuminosity) * (luminosity - 1.0) / (1.0 - haloLuminosity) + 1.0;
    }

, Color.FromArgb(255, 246, 246, 246). , . :

+2

All Articles