Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f2a40f051b | ||
|
|
17c8960cdd | ||
|
|
b5f526e244 |
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 |
@@ -1,35 +1,32 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
|
using System.Drawing.Drawing2D;
|
||||||
|
|
||||||
namespace SGU.CredentialProvider;
|
namespace SGU.CredentialProvider;
|
||||||
|
|
||||||
internal static class ProviderTileIcon
|
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()
|
public static Bitmap Create()
|
||||||
{
|
{
|
||||||
Bitmap bitmap = new(Size, Size, PixelFormat.Format32bppArgb);
|
Bitmap bitmap = new(Size, Size, PixelFormat.Format32bppArgb);
|
||||||
using Graphics graphics = Graphics.FromImage(bitmap);
|
using Graphics graphics = Graphics.FromImage(bitmap);
|
||||||
graphics.SmoothingMode = SmoothingMode.AntiAlias;
|
graphics.CompositingQuality = CompositingQuality.HighQuality;
|
||||||
|
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||||
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
||||||
graphics.Clear(Color.Transparent);
|
graphics.Clear(Color.Transparent);
|
||||||
|
|
||||||
using SolidBrush background = new(Color.FromArgb(0, 83, 155));
|
using Stream sourceStream = typeof(ProviderTileIcon).Assembly.GetManifestResourceStream(MascotResourceName)
|
||||||
graphics.FillEllipse(background, 1, 1, Size - 2, Size - 2);
|
?? throw new InvalidOperationException($"The branded Credential Provider logo '{MascotResourceName}' is unavailable.");
|
||||||
|
using Bitmap mascot = new(sourceStream);
|
||||||
using Pen key = new(Color.White, 5.5f)
|
using GraphicsPath circularMask = new();
|
||||||
{
|
circularMask.AddEllipse(0, 0, Size, Size);
|
||||||
StartCap = LineCap.Round,
|
graphics.SetClip(circularMask);
|
||||||
EndCap = LineCap.Round,
|
graphics.DrawImage(mascot, new Rectangle(0, 0, Size, Size));
|
||||||
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);
|
|
||||||
|
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,11 @@
|
|||||||
<ProjectReference Include="..\SGU.AuthBroker.Core\SGU.AuthBroker.Core.csproj" />
|
<ProjectReference Include="..\SGU.AuthBroker.Core\SGU.AuthBroker.Core.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="..\..\assets\branding\lasalle-mexico-provider.png"
|
||||||
|
LogicalName="SGU.CredentialProvider.Branding.LaSalleMascot.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
|
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
|
||||||
<_Parameter1>SGU.CredentialProvider.Tests</_Parameter1>
|
<_Parameter1>SGU.CredentialProvider.Tests</_Parameter1>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace SGU.CredentialProvider.Tests;
|
|||||||
public sealed class ProviderTileIconTests
|
public sealed class ProviderTileIconTests
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ProviderPublishesASeventyTwoPixelLogoForSignInOptions()
|
public void ProviderPublishesAHighResolutionLogoForSignInOptions()
|
||||||
{
|
{
|
||||||
SguCredentialProvider provider = new();
|
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(ProviderTileIcon.Size - 1, 0).A);
|
||||||
Assert.Equal(0, logo.Bitmap.GetPixel(0, ProviderTileIcon.Size - 1).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(0, logo.Bitmap.GetPixel(ProviderTileIcon.Size - 1, ProviderTileIcon.Size - 1).A);
|
||||||
Assert.Equal(
|
int redPixels = 0;
|
||||||
Color.FromArgb(0, 83, 155).ToArgb(),
|
int navyPixels = 0;
|
||||||
logo.Bitmap.GetPixel(6, ProviderTileIcon.Size / 2).ToArgb());
|
|
||||||
int lightPixels = 0;
|
|
||||||
for (int x = 0; x < logo.Bitmap.Width; x++)
|
for (int x = 0; x < logo.Bitmap.Width; x++)
|
||||||
{
|
{
|
||||||
for (int y = 0; y < logo.Bitmap.Height; y++)
|
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]
|
[Fact]
|
||||||
|
|||||||
Reference in New Issue
Block a user