dynamically convert png to ico to reduce file size

This commit is contained in:
Kang Yu 2024-01-19 14:42:27 -08:00
parent dd20274ce3
commit 09f9717b48
7 changed files with 27 additions and 7 deletions

View file

@ -251,7 +251,7 @@ namespace PersistentWindows.SystrayShell
icon_path2 = Path.Combine(appDataFolder, "pwIconBusy.png");
if (File.Exists(icon_path2))
{
var bitmap = new System.Drawing.Bitmap(icon_path2); // or get it from resource
var bitmap = new System.Drawing.Bitmap(icon_path2);
var iconHandle = bitmap.GetHicon();
BusyIcon = System.Drawing.Icon.FromHandle(iconHandle);
}
@ -260,8 +260,9 @@ namespace PersistentWindows.SystrayShell
BusyIcon = new System.Drawing.Icon(icon_path);
}
else
{
BusyIcon = Properties.Resources.pwIconBusy;
{
var iconHandle = Properties.Resources.pwIconBusy.GetHicon();
BusyIcon = System.Drawing.Icon.FromHandle(iconHandle);
}
systrayForm = new SystrayForm();

View file

@ -71,12 +71,22 @@ namespace PersistentWindows.SystrayShell.Properties {
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Icon pwIconBusy {
internal static System.Drawing.Bitmap pwIconBusy {
get {
object obj = ResourceManager.GetObject("pwIconBusy", resourceCulture);
return ((System.Drawing.Icon)(obj));
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap pwIconUpdate {
get {
object obj = ResourceManager.GetObject("pwIconUpdate", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}

View file

@ -122,7 +122,10 @@
<value>..\Resources\pwIcon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="pwIconBusy" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\pwIconBusy.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<value>..\Resources\pwIconBusy.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="pwIconUpdate" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\pwIconUpdate.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="question" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\question.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -123,6 +123,12 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<None Include="Resources\pwIconBusy.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\pwIconUpdate.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy $(SolutionDir)*.bat $(TargetDir)