Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/Lithnet.CredentialProvider/Controls/BitmapControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ protected BitmapControl(string key, string label, bool isProviderLogo, Bitmap bi

protected BitmapControl(BitmapControl source) : base(source) { }

/// <summary>
/// Gets or sets a value indicating whether the bitmap should be displayed with transparency enabled.
/// </summary>
public bool EnableTransparent { get; set; } = false;

/// <summary>
/// Specifies the background color that should replace any transparent elements of the image. This defaults to #707070
/// </summary>
Expand Down Expand Up @@ -84,11 +89,15 @@ internal IntPtr GetBitmapBuffer(out uint size)
}

var image = Bitmap.FromHbitmap(hbitmap);

if (this.EnableTransparent)
{
image.MakeTransparent(this.BackgroundColor);
}
IntPtr buffer = IntPtr.Zero;
using (MemoryStream ms = new MemoryStream())
{
image.Save(ms, ImageFormat.Bmp);
var format = this.EnableTransparent ? ImageFormat.Png : ImageFormat.Bmp;
image.Save(ms, format);
var bitmapBytes = ms.ToArray();
size = (uint)bitmapBytes.Length;
buffer = Marshal.AllocCoTaskMem(bitmapBytes.Length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Lithnet.CredentialProvider
{
internal abstract partial class CredentialTile3 : ICredentialProviderCredential3
public abstract partial class CredentialTile3 : ICredentialProviderCredential3
{
int ICredentialProviderCredential3.GetBitmapBufferValue(uint dwFieldID, out uint pImageBufferSize, out IntPtr ppImageBuffer)
{
Expand All @@ -19,6 +19,7 @@ int ICredentialProviderCredential3.GetBitmapBufferValue(uint dwFieldID, out uint
if (this.Controls.TryGetControl<BitmapControl>(dwFieldID, FieldType.TileImage, out var instance))
{
var hbitmap = instance.GetBitmapBuffer(out pImageBufferSize);
ppImageBuffer = hbitmap;
return HRESULT.S_OK;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Lithnet.CredentialProvider/CredentialTile3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Lithnet.CredentialProvider
/// Represents a user credential tile that implements the functionality of <see cref="CredentialTile"/> and <see cref="CredentialTile2"/>, but includes support for dynamically updating bitmap images.
/// </summary>
/// <remarks>This interface is public, but undocumented by Microsoft. It is recommended to use <see cref="CredentialTile2"/> tiles unless this specific functionality is needed</remarks>
internal abstract partial class CredentialTile3 : CredentialTile2
public abstract partial class CredentialTile3 : CredentialTile2
{
protected CredentialTile3(CredentialProviderBase credentialProvider) : this(credentialProvider, null) { }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0-windows;net7.0-windows;net8.0-windows;net461</TargetFrameworks>
<TargetFrameworks>net10.0-windows;net7.0-windows;net8.0-windows;net461</TargetFrameworks>
<RegisterForComInterop>false</RegisterForComInterop>
<OutputType>Library</OutputType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand All @@ -17,8 +17,7 @@
<Company>Lithnet</Company>
<Copyright>Copyright 2023 Lithnet Pty Ltd</Copyright>
<ProductName>Lithnet Windows Credential Provider</ProductName>
<VersionPrefix>1.1.0</VersionPrefix>
<VersionSuffix>beta1</VersionSuffix>
<VersionPrefix>1.1.28</VersionPrefix>
<Authors>Lithnet</Authors>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<AutoIncrementPackageRevision>true</AutoIncrementPackageRevision>
Expand Down