Compare commits

...
3 Commits
6 changed files with 32 additions and 25 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

+14 -17
View File
@@ -1,35 +1,32 @@
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
namespace SGU.CredentialProvider;
internal static class ProviderTileIcon
{
public const int Size = 72;
// 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.SmoothingMode = SmoothingMode.AntiAlias;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
graphics.Clear(Color.Transparent);
using SolidBrush background = new(Color.FromArgb(0, 83, 155));
graphics.FillEllipse(background, 1, 1, Size - 2, Size - 2);
using Pen key = new(Color.White, 5.5f)
{
StartCap = LineCap.Round,
EndCap = LineCap.Round,
LineJoin = LineJoin.Round
};
graphics.DrawEllipse(key, 14, 14, 25, 25);
graphics.DrawLine(key, 35, 35, 57, 57);
graphics.DrawLine(key, 47, 47, 55, 39);
graphics.DrawLine(key, 53, 53, 61, 45);
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;
}
@@ -23,6 +23,11 @@
<ProjectReference Include="..\SGU.AuthBroker.Core\SGU.AuthBroker.Core.csproj" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="..\..\assets\branding\lasalle-mexico-provider.png"
LogicalName="SGU.CredentialProvider.Branding.LaSalleMascot.png" />
</ItemGroup>
<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
<_Parameter1>SGU.CredentialProvider.Tests</_Parameter1>
@@ -7,7 +7,7 @@ namespace SGU.CredentialProvider.Tests;
public sealed class ProviderTileIconTests
{
[Fact]
public void ProviderPublishesASeventyTwoPixelLogoForSignInOptions()
public void ProviderPublishesAHighResolutionLogoForSignInOptions()
{
SguCredentialProvider provider = new();
@@ -20,22 +20,27 @@ public sealed class ProviderTileIconTests
Assert.Equal(0, logo.Bitmap.GetPixel(ProviderTileIcon.Size - 1, 0).A);
Assert.Equal(0, logo.Bitmap.GetPixel(0, ProviderTileIcon.Size - 1).A);
Assert.Equal(0, logo.Bitmap.GetPixel(ProviderTileIcon.Size - 1, ProviderTileIcon.Size - 1).A);
Assert.Equal(
Color.FromArgb(0, 83, 155).ToArgb(),
logo.Bitmap.GetPixel(6, ProviderTileIcon.Size / 2).ToArgb());
int lightPixels = 0;
int redPixels = 0;
int navyPixels = 0;
for (int x = 0; x < logo.Bitmap.Width; x++)
{
for (int y = 0; y < logo.Bitmap.Height; y++)
{
if (logo.Bitmap.GetPixel(x, y).GetBrightness() > 0.7f)
Color pixel = logo.Bitmap.GetPixel(x, y);
if (pixel.R > 160 && pixel.G < 100 && pixel.B < 100)
{
lightPixels++;
redPixels++;
}
if (pixel.B > pixel.R && pixel.B > pixel.G && pixel.R < 70)
{
navyPixels++;
}
}
}
Assert.InRange(lightPixels, 200, 2_000);
Assert.InRange(redPixels, 1_000, 30_000);
Assert.InRange(navyPixels, 1_000, 50_000);
}
[Fact]