OpenHardwareMonitor.GUI.SensorNotifyIcon.CreateTransparentIcon C# (CSharp) Method

CreateTransparentIcon() private method

private CreateTransparentIcon ( ) : Icon
return System.Drawing.Icon
        private Icon CreateTransparentIcon()
        {
            graphics.Clear(Color.Black);
              TextRenderer.DrawText(graphics, GetString(), font,
            new Point(-2, 0), Color.White, Color.Black);

              BitmapData data = bitmap.LockBits(
            new Rectangle(0, 0, bitmap.Width, bitmap.Height),
            ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);

              IntPtr Scan0 = data.Scan0;

              int numBytes = bitmap.Width * bitmap.Height * 4;
              byte[] bytes = new byte[numBytes];
              Marshal.Copy(Scan0, bytes, 0, numBytes);
              bitmap.UnlockBits(data);

              byte red, green, blue;
              for (int i = 0; i < bytes.Length; i += 4) {
            blue = bytes[i];
            green = bytes[i + 1];
            red = bytes[i + 2];

            bytes[i] = color.B;
            bytes[i + 1] = color.G;
            bytes[i + 2] = color.R;
            bytes[i + 3] = (byte)(0.3 * red + 0.59 * green + 0.11 * blue);
              }

              return IconFactory.Create(bytes, bitmap.Width, bitmap.Height,
            PixelFormat.Format32bppArgb);
        }