Example #1
0
        private static Bitmap GetBitmapFromIcon(string iconName)
        {
            Size   desiredSize = new Size(s_iconsWidth, s_iconsHeight);
            Icon   icon        = new Icon(new Icon(typeof(DataGridViewHeaderCell), iconName), desiredSize);
            Bitmap b           = icon.ToBitmap();

            icon.Dispose();

            if (DpiHelper.IsScalingRequired && (b.Size.Width != s_iconsWidth || b.Size.Height != s_iconsHeight))
            {
                Bitmap scaledBitmap = DpiHelper.CreateResizedBitmap(b, desiredSize);
                if (scaledBitmap != null)
                {
                    b.Dispose();
                    b = scaledBitmap;
                }
            }
            return(b);
        }