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
14 changes: 14 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ The first parameter can be either the path to the png, or a `Bitmap` object. The

### History

### IconLib 1.0 (01/28/2019)

some bugfixes for 64bit windows
codeanalysis fixes

added projectfiles for .net4.0 with MIT License
signed assembly and installer for GAC added
PublicKeyToken=d586bf32134c8d42, AssemblyVersion=4.0

### IconLib 0.74 (12/30/2017)

Fixed a small problem with saving icon files (bHeight in ICONDIRENTRY and GRPICONDIRENTRY had doubled value).
Namespace corrections for the resource designer file.

### IconLib 0.73 (01/31/2008)

Fixed a small problem with indexed 8bpp images.
Expand Down
Binary file modified iconlib_demo/IconLib.dll
Binary file not shown.
Binary file modified iconlib_demo/MultiIcon.exe
Binary file not shown.
23 changes: 23 additions & 0 deletions iconlib_src/IconLib/BuildMsi.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
:: Color 0C
@echo For a newer version change the Program ID and Version Infos in the wxs file.
@echo ---------------------------------------------------------------------------
:: Color 07
@echo off
:: @set INPUT=
:: @set /P INPUT=Type Version (e.g. V1.2): %=%
echo on
if not defined ProgramFiles(x86) goto x86
rem 64Bit Systems
Set X86ProgramFiles=%ProgramFiles(x86)%
goto x86End

:x86
rem 32Bit Systems
Set X86ProgramFiles=%ProgramFiles%
:x86End

Set AppName=IconLib.Net4
Set Wix3xPath=%X86ProgramFiles%\WiX Toolset v3.11\bin
"%Wix3xPath%\candle.exe" -nologo %AppName%.wxs -out %AppName%.wixobj
"%Wix3xPath%\light.exe" -nologo %AppName%.wixobj -out %AppName%.msi -ext WixUtilExtension -ext WixUIExtension -ext WixNetFxExtension
pause
120 changes: 120 additions & 0 deletions iconlib_src/IconLib/IconLib.Net4.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="15.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{B8893240-CA7C-4AE9-A1BF-A32D080EFBD6}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>
</RootNamespace>
<AssemblyName>IconLib</AssemblyName>
<SccProjectName>
</SccProjectName>
<SccLocalPath>
</SccLocalPath>
<SccAuxPath>
</SccAuxPath>
<SccProvider>
</SccProvider>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>2.0</OldToolsVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin4\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;Net4</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin4\Release\</OutputPath>
<DefineConstants>TRACE;Net4</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>iconlib.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="System\Drawing\IconLib\AuthorAttribute.cs" />
<Compile Include="System\Drawing\IconLib\ColorProcessing\EuclideanQuantizer.cs" />
<Compile Include="System\Drawing\IconLib\ColorProcessing\FloydSteinbergDithering.cs" />
<Compile Include="System\Drawing\IconLib\ColorProcessing\IColorQuantizer.cs" />
<Compile Include="System\Drawing\IconLib\ColorProcessing\IDithering.cs" />
<Compile Include="System\Drawing\IconLib\ColorProcessing\IPaletteQuantizer.cs" />
<Compile Include="System\Drawing\IconLib\ColorProcessing\OctreeQuantizer.cs" />
<Compile Include="System\Drawing\IconLib\Exceptions\InvalidPixelFormatException.cs" />
<Compile Include="System\Drawing\IconLib\LibraryFormats\ILibraryFormat.cs" />
<Compile Include="System\Drawing\IconLib\BitmapEncoders\BMPEncoder.cs" />
<Compile Include="System\Drawing\IconLib\BitmapEncoders\PNGEncoder.cs" />
<Compile Include="System\Drawing\IconLib\BitmapEncoders\ImageEncoder.cs" />
<Compile Include="System\Drawing\IconLib\Exceptions\InvalidIconFormatSelectionException.cs" />
<Compile Include="System\Drawing\IconLib\Exceptions\InvalidIconSelectionException.cs" />
<Compile Include="System\Drawing\IconLib\Exceptions\InvalidICLFileException.cs" />
<Compile Include="System\Drawing\IconLib\Exceptions\IconNameAlreadyExistException.cs" />
<Compile Include="System\Drawing\IconLib\Exceptions\ImageAlreadyExistsException.cs" />
<Compile Include="System\Drawing\IconLib\Exceptions\ImageTooBigException.cs" />
<Compile Include="System\Drawing\IconLib\Exceptions\InvalidMultiIconFileException.cs" />
<Compile Include="System\Drawing\IconLib\Exceptions\InvalidMultiIconMaskBitmap.cs" />
<Compile Include="System\Drawing\IconLib\LibraryFormats\IconFormat.cs" />
<Compile Include="System\Drawing\IconLib\Enums.cs" />
<Compile Include="System\Drawing\IconLib\Exceptions\InvalidFileException.cs" />
<Compile Include="System\Drawing\IconLib\MultiIcon.cs" />
<Compile Include="System\Drawing\IconLib\LibraryFormats\NEFormat.cs" />
<Compile Include="System\Drawing\IconLib\IconImage.cs" />
<Compile Include="System\Drawing\IconLib\LibraryFormats\PEFormat.cs" />
<Compile Include="System\Drawing\IconLib\Resource.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resource.resx</DependentUpon>
</Compile>
<Compile Include="System\Drawing\IconLib\SingleIcon.cs" />
<Compile Include="System\Drawing\IconLib\Structs.cs" />
<Compile Include="System\Drawing\IconLib\Tools.cs" />
<Compile Include="System\Drawing\IconLib\Win32.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="System\Drawing\IconLib\Resource.resx">
<SubType>Designer</SubType>
<Generator>ResXFileCodeGenerator</Generator>
<CustomToolNamespace>System.Drawing.IconLib</CustomToolNamespace>
<LastGenOutput>Resource.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="iconlib.snk" />
<None Include="Resources\EmptyDll.dll" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
60 changes: 60 additions & 0 deletions iconlib_src/IconLib/IconLib.Net4.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
# This comment is generated by WixEdit, the specific commandline
# arguments for the WiX Toolset are stored here.

candleArgs:
lightArgs: "<projectname>.wixobj" -out "<projectname>.msi" -ext WixUIExtension -ext WixNetFxExtension
-->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="B75F341F-9466-4C20-A91E-819BBD520ABE" Name="IconLib" Language="1033" Version="0.75.0.0" Manufacturer="Harborsiem" UpgradeCode="2374BC1D-998C-4BE5-A057-C5645E73F87D">
<Package Description="Icon Library for .NET Framework 4" InstallerVersion="301" Compressed="yes" Manufacturer="Harborsiem" Keywords="Microsoft Windows Installer, MSI" Platform="x86" InstallScope="perMachine" />
<Media Id="1" Cabinet="Data.cab" EmbedCab="yes" />
<MajorUpgrade DowngradeErrorMessage="A later version of [ProductName] is already installed." Schedule="afterInstallValidate" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder" Name="ProgramFiles">
<Directory Id="Di.IconLib" Name="IconLib">
<Directory Id="Di.Bin4" Name="bin4">
</Directory>
</Directory>
</Directory>
</Directory>
<DirectoryRef Id="TARGETDIR">
<Component Id="C.RegistryEntries" Guid="CDBA3CF3-4C03-4E2D-9E2B-65A9D6150B0F">
<!--
.NET2.0, 3.5 GAC Assembly
<RegistryKey Root="HKLM" Key="Software\Microsoft\.NETFramework\AssemblyFolders\[ProductName]" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes" Id="R.AssemblyRef">
<RegistryValue Type="string" Value="[ProgramFilesFolder]IconLib\bin4\" KeyPath="yes" />
</RegistryKey>
-->
<!--
.NET4.x GAC Assembly
-->
<RegistryKey Root="HKLM" Key="Software\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx\[ProductName]" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes" Id="R.AssemblyRef">
<RegistryValue Type="string" Value="[ProgramFilesFolder]IconLib\bin4\" KeyPath="yes" />
</RegistryKey>
</Component>
</DirectoryRef>
<DirectoryRef Id="TARGETDIR">
<Component Id="C.GacDll" Guid="01F51411-F30B-4BE4-AA31-A2C6FF99C3EB">
<File Id="Fi.GacDll" Name="IconLib.dll" Source="bin4\Release\IconLib.dll" KeyPath="yes" Assembly=".net" />
</Component>
</DirectoryRef>
<DirectoryRef Id="Di.Bin4">
<Component Id="C.Bin4" Guid="B803C1EE-53A5-44A5-8C67-2DA469D97479">
<File Id="Fi.DllClone" Name="IconLib.dll" Source="bin4\Release\IconLib.dll" KeyPath="yes" />
</Component>
</DirectoryRef>
<UI />
<PropertyRef Id="NETFRAMEWORK40FULL" />
<Condition Message="This library requires .NET Framework 4.0.">Installed OR NETFRAMEWORK40FULL</Condition>
<Feature Id="DefaultFeature" Level="1">
<ComponentRef Id="C.Bin4" />
<ComponentRef Id="C.GacDll" Primary="yes" />
<ComponentRef Id="C.RegistryEntries" />
</Feature>
<UIRef Id="WixUI_Minimal" />
<UIRef Id="WixUI_ErrorProgressText" />
<WixVariable Id="WixUILicenseRtf" Value="MIT_License.rtf" />
</Product>
</Wix>
13 changes: 10 additions & 3 deletions iconlib_src/IconLib/IconLib.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="15.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand All @@ -7,7 +7,8 @@
<ProjectGuid>{CE53747F-D2E6-4E1E-9EF4-A0AE02671B1D}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>IconLib</RootNamespace>
<RootNamespace>
</RootNamespace>
<AssemblyName>IconLib</AssemblyName>
<SccProjectName>
</SccProjectName>
Expand All @@ -17,6 +18,12 @@
</SccAuxPath>
<SccProvider>
</SccProvider>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>2.0</OldToolsVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -87,7 +94,7 @@
<EmbeddedResource Include="System\Drawing\IconLib\Resource.resx">
<SubType>Designer</SubType>
<Generator>ResXFileCodeGenerator</Generator>
<CustomToolNamespace>System.Drawing.IconLIb</CustomToolNamespace>
<CustomToolNamespace>System.Drawing.IconLib</CustomToolNamespace>
<LastGenOutput>Resource.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
Expand Down
Binary file added iconlib_src/IconLib/MIT_License.rtf
Binary file not shown.
17 changes: 14 additions & 3 deletions iconlib_src/IconLib/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

Expand All @@ -7,13 +7,20 @@
// associated with an assembly.
[assembly: AssemblyTitle("IconLib")]
[assembly: AssemblyDescription("")]
#if Net4
[assembly: AssemblyConfiguration(".NET4")]
#else
[assembly: AssemblyConfiguration("")]
#endif
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("IconLib")]
[assembly: AssemblyCopyright("Copyright © Franco, Gustavo 2006")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

//[assembly: System.Security.SecurityCritical]
//[assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level2)]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
Expand All @@ -31,5 +38,9 @@
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("0.73.0.0")]
[assembly: AssemblyFileVersion("0.73.0.0")]
#if Net4
[assembly: AssemblyVersion("4.0.0.0")]
#else
[assembly: AssemblyVersion("0.74.0.0")]
#endif
[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using System.Text;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Security.Permissions;

namespace System.Drawing.IconLib.BitmapEncoders
{
Expand All @@ -45,6 +46,8 @@ public unsafe virtual Icon Icon
{
get
{
new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();

MemoryStream ms = new MemoryStream();

// ICONDIR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using System.Drawing.IconLib;
using System.Drawing.Imaging;
using System.Collections.Generic;
using System.Security.Permissions;

namespace System.Drawing.IconLib.ColorProcessing
{
Expand All @@ -42,7 +43,7 @@ public class EuclideanQuantizer : IColorQuantizer
public EuclideanQuantizer(IPaletteQuantizer quantizer, IDithering dithering)
{
if (quantizer == null)
throw new Exception("param 'quantizer' cannot be null");
throw new ArgumentNullException("quantizer", "param 'quantizer' cannot be null");

mQuantizer = quantizer;
mDithering = dithering;
Expand All @@ -52,10 +53,12 @@ public EuclideanQuantizer(IPaletteQuantizer quantizer, IDithering dithering)
#region Methods
public unsafe Bitmap Convert(Bitmap source, PixelFormat outputFormat)
{
new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();

DateTime dt1 = DateTime.Now;

if ((outputFormat & PixelFormat.Indexed) != PixelFormat.Indexed)
throw new Exception("Output format must be one of the indexed formats");
throw new ArgumentException("Output format must be one of the indexed formats", "outputFormat");

Bitmap bmpTrg = new Bitmap(source.Width, source.Height, outputFormat);

Expand All @@ -80,7 +83,7 @@ public unsafe Bitmap Convert(Bitmap source, PixelFormat outputFormat)
newPalette = mQuantizer.CreatePalette(source, 256, 8);
break;
default:
throw new Exception("Indexed format not supported");
throw new ArgumentException("Indexed format not supported", "outputFormat");
}

DateTime dt2 = DateTime.Now;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using System.Collections.Generic;
using System.Text;
using System.Drawing.Imaging;
using System.Security.Permissions;

namespace System.Drawing.IconLib.ColorProcessing
{
Expand All @@ -35,6 +36,8 @@ public OctreeQuantizer()
#region Methods
public unsafe ColorPalette CreatePalette(Bitmap image, int maxColors, int bitsPerPixel)
{
new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();

int nPad;
byte* pbBits;
ushort* pwBits;
Expand All @@ -50,7 +53,7 @@ public unsafe ColorPalette CreatePalette(Bitmap image, int maxColors, int bitsPe
Node[] reducibleNodes = new Node[9];

if (maxColors > Math.Pow(2, bitsPerPixel))
throw new Exception("param maxColors out of range, maximum " + Math.Pow(2, bitsPerPixel) + " colors for " + bitsPerPixel + " bits");
throw new ArgumentException("param maxColors out of range, maximum " + Math.Pow(2, bitsPerPixel) + " colors for " + bitsPerPixel + " bits", "bitsPerPixel");

//// Initialize octree variables
tree = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
namespace System.Drawing.IconLib.Exceptions
{
[Author("Franco, Gustavo")]
[Serializable]
public class IconNameAlreadyExistException : Exception
{
#region Constructors
Expand Down
Loading