using System.Drawing; using System.Drawing.Imaging; using System.Drawing.Drawing2D; namespace SGU.CredentialProvider; internal static class ProviderTileIcon { // LogonUI enlarges the dedicated-tile artwork. Supply a dense source image // so the mascot remains crisp at the large sign-in surface. public const int Size = 256; private const string MascotResourceName = "SGU.CredentialProvider.Branding.LaSalleMascot.png"; public static Bitmap Create() { Bitmap bitmap = new(Size, Size, PixelFormat.Format32bppArgb); using Graphics graphics = Graphics.FromImage(bitmap); graphics.CompositingQuality = CompositingQuality.HighQuality; graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; graphics.Clear(Color.Transparent); using Stream sourceStream = typeof(ProviderTileIcon).Assembly.GetManifestResourceStream(MascotResourceName) ?? throw new InvalidOperationException($"The branded Credential Provider logo '{MascotResourceName}' is unavailable."); using Bitmap mascot = new(sourceStream); using GraphicsPath circularMask = new(); circularMask.AddEllipse(0, 0, Size, Size); graphics.SetClip(circularMask); graphics.DrawImage(mascot, new Rectangle(0, 0, Size, Size)); return bitmap; } }