diff --git a/Readme.md b/Readme.md index c665c27..7971438 100644 --- a/Readme.md +++ b/Readme.md @@ -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. diff --git a/iconlib_demo/IconLib.dll b/iconlib_demo/IconLib.dll index c682c9b..834ce77 100644 Binary files a/iconlib_demo/IconLib.dll and b/iconlib_demo/IconLib.dll differ diff --git a/iconlib_demo/MultiIcon.exe b/iconlib_demo/MultiIcon.exe index 0d10436..f49a53a 100644 Binary files a/iconlib_demo/MultiIcon.exe and b/iconlib_demo/MultiIcon.exe differ diff --git a/iconlib_src/IconLib/BuildMsi.bat b/iconlib_src/IconLib/BuildMsi.bat new file mode 100644 index 0000000..ad0e9b8 --- /dev/null +++ b/iconlib_src/IconLib/BuildMsi.bat @@ -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 diff --git a/iconlib_src/IconLib/IconLib.Net4.csproj b/iconlib_src/IconLib/IconLib.Net4.csproj new file mode 100644 index 0000000..96ee7b6 --- /dev/null +++ b/iconlib_src/IconLib/IconLib.Net4.csproj @@ -0,0 +1,120 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {B8893240-CA7C-4AE9-A1BF-A32D080EFBD6} + Library + Properties + + + IconLib + + + + + + + + + v4.0 + + + + + 2.0 + + + + true + full + false + bin4\Debug\ + TRACE;DEBUG;Net4 + prompt + 4 + true + + + pdbonly + true + bin4\Release\ + TRACE;Net4 + prompt + 4 + true + + + true + + + iconlib.snk + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + True + True + Resource.resx + + + + + + + + + Designer + ResXFileCodeGenerator + System.Drawing.IconLib + Resource.Designer.cs + + + + + + + + + \ No newline at end of file diff --git a/iconlib_src/IconLib/IconLib.Net4.wxs b/iconlib_src/IconLib/IconLib.Net4.wxs new file mode 100644 index 0000000..bb9d01c --- /dev/null +++ b/iconlib_src/IconLib/IconLib.Net4.wxs @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Installed OR NETFRAMEWORK40FULL + + + + + + + + + + \ No newline at end of file diff --git a/iconlib_src/IconLib/IconLib.csproj b/iconlib_src/IconLib/IconLib.csproj index 9dd73ab..0a27d34 100644 --- a/iconlib_src/IconLib/IconLib.csproj +++ b/iconlib_src/IconLib/IconLib.csproj @@ -1,4 +1,4 @@ - + Debug AnyCPU @@ -7,7 +7,8 @@ {CE53747F-D2E6-4E1E-9EF4-A0AE02671B1D} Library Properties - IconLib + + IconLib @@ -17,6 +18,12 @@ + v2.0 + + + + + 2.0 true @@ -87,7 +94,7 @@ Designer ResXFileCodeGenerator - System.Drawing.IconLIb + System.Drawing.IconLib Resource.Designer.cs diff --git a/iconlib_src/IconLib/MIT_License.rtf b/iconlib_src/IconLib/MIT_License.rtf new file mode 100644 index 0000000..b4a397f Binary files /dev/null and b/iconlib_src/IconLib/MIT_License.rtf differ diff --git a/iconlib_src/IconLib/Properties/AssemblyInfo.cs b/iconlib_src/IconLib/Properties/AssemblyInfo.cs index ce7827c..bd0f9a3 100644 --- a/iconlib_src/IconLib/Properties/AssemblyInfo.cs +++ b/iconlib_src/IconLib/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -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. @@ -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")] diff --git a/iconlib_src/IconLib/System/Drawing/IconLib/BitmapEncoders/ImageEncoder.cs b/iconlib_src/IconLib/System/Drawing/IconLib/BitmapEncoders/ImageEncoder.cs index cb29c41..a03c165 100644 --- a/iconlib_src/IconLib/System/Drawing/IconLib/BitmapEncoders/ImageEncoder.cs +++ b/iconlib_src/IconLib/System/Drawing/IconLib/BitmapEncoders/ImageEncoder.cs @@ -21,6 +21,7 @@ using System.Text; using System.Collections.Generic; using System.Runtime.InteropServices; +using System.Security.Permissions; namespace System.Drawing.IconLib.BitmapEncoders { @@ -45,6 +46,8 @@ public unsafe virtual Icon Icon { get { + new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand(); + MemoryStream ms = new MemoryStream(); // ICONDIR diff --git a/iconlib_src/IconLib/System/Drawing/IconLib/ColorProcessing/EuclideanQuantizer.cs b/iconlib_src/IconLib/System/Drawing/IconLib/ColorProcessing/EuclideanQuantizer.cs index a405ce9..51f33eb 100644 --- a/iconlib_src/IconLib/System/Drawing/IconLib/ColorProcessing/EuclideanQuantizer.cs +++ b/iconlib_src/IconLib/System/Drawing/IconLib/ColorProcessing/EuclideanQuantizer.cs @@ -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 { @@ -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; @@ -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); @@ -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; diff --git a/iconlib_src/IconLib/System/Drawing/IconLib/ColorProcessing/OctreeQuantizer.cs b/iconlib_src/IconLib/System/Drawing/IconLib/ColorProcessing/OctreeQuantizer.cs index 9a32b63..8841bce 100644 --- a/iconlib_src/IconLib/System/Drawing/IconLib/ColorProcessing/OctreeQuantizer.cs +++ b/iconlib_src/IconLib/System/Drawing/IconLib/ColorProcessing/OctreeQuantizer.cs @@ -20,6 +20,7 @@ using System.Collections.Generic; using System.Text; using System.Drawing.Imaging; +using System.Security.Permissions; namespace System.Drawing.IconLib.ColorProcessing { @@ -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; @@ -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; diff --git a/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/IconNameAlreadyExistException.cs b/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/IconNameAlreadyExistException.cs index bb4d76a..e625a23 100644 --- a/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/IconNameAlreadyExistException.cs +++ b/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/IconNameAlreadyExistException.cs @@ -19,6 +19,7 @@ namespace System.Drawing.IconLib.Exceptions { [Author("Franco, Gustavo")] + [Serializable] public class IconNameAlreadyExistException : Exception { #region Constructors diff --git a/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/ImageAlreadyExistsException.cs b/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/ImageAlreadyExistsException.cs index 23bb29a..20c191e 100644 --- a/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/ImageAlreadyExistsException.cs +++ b/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/ImageAlreadyExistsException.cs @@ -19,6 +19,7 @@ namespace System.Drawing.IconLib.Exceptions { [Author("Franco, Gustavo")] + [Serializable] public class ImageAlreadyExistsException : Exception { #region Constructors diff --git a/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/ImageTooBigException.cs b/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/ImageTooBigException.cs index 44f245a..c23b44e 100644 --- a/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/ImageTooBigException.cs +++ b/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/ImageTooBigException.cs @@ -19,6 +19,7 @@ namespace System.Drawing.IconLib.Exceptions { [Author("Franco, Gustavo")] + [Serializable] public class ImageTooBigException : Exception { #region Constructors diff --git a/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/InvalidFileException.cs b/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/InvalidFileException.cs index 6264ca8..05a327a 100644 --- a/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/InvalidFileException.cs +++ b/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/InvalidFileException.cs @@ -19,6 +19,7 @@ namespace System.Drawing.IconLib.Exceptions { [Author("Franco, Gustavo")] + [Serializable] public class InvalidFileException : Exception { #region Constructors diff --git a/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/InvalidICLFileException.cs b/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/InvalidICLFileException.cs index 991e172..e4de17d 100644 --- a/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/InvalidICLFileException.cs +++ b/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/InvalidICLFileException.cs @@ -20,6 +20,7 @@ namespace System.Drawing.IconLib.Exceptions { [Author("Franco, Gustavo")] + [Serializable] public class InvalidICLFileException : Exception { #region Constructors diff --git a/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/InvalidIconFormatSelectionException.cs b/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/InvalidIconFormatSelectionException.cs index 49fb8cf..46106bd 100644 --- a/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/InvalidIconFormatSelectionException.cs +++ b/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/InvalidIconFormatSelectionException.cs @@ -19,6 +19,7 @@ namespace System.Drawing.IconLib.Exceptions { [Author("Franco, Gustavo")] + [Serializable] public class InvalidIconFormatSelectionException : Exception { #region Constructors diff --git a/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/InvalidIconSelectionException.cs b/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/InvalidIconSelectionException.cs index 0b5a7e4..94ce4bf 100644 --- a/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/InvalidIconSelectionException.cs +++ b/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/InvalidIconSelectionException.cs @@ -19,6 +19,7 @@ namespace System.Drawing.IconLib.Exceptions { [Author("Franco, Gustavo")] + [Serializable] public class InvalidIconSelectionException : Exception { #region Constructors diff --git a/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/InvalidMultiIconFileException.cs b/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/InvalidMultiIconFileException.cs index 6a8a419..276b937 100644 --- a/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/InvalidMultiIconFileException.cs +++ b/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/InvalidMultiIconFileException.cs @@ -19,6 +19,7 @@ namespace System.Drawing.IconLib.Exceptions { [Author("Franco, Gustavo")] + [Serializable] public class InvalidMultiIconFileException : Exception { #region Constructors diff --git a/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/InvalidMultiIconMaskBitmap.cs b/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/InvalidMultiIconMaskBitmap.cs index 83ddc29..960fc92 100644 --- a/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/InvalidMultiIconMaskBitmap.cs +++ b/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/InvalidMultiIconMaskBitmap.cs @@ -19,6 +19,7 @@ namespace System.Drawing.IconLib.Exceptions { [Author("Franco, Gustavo")] + [Serializable] public class InvalidMultiIconMaskBitmap : Exception { #region Constructors diff --git a/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/InvalidPixelFormatException.cs b/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/InvalidPixelFormatException.cs index dfce673..0bb1e4d 100644 --- a/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/InvalidPixelFormatException.cs +++ b/iconlib_src/IconLib/System/Drawing/IconLib/Exceptions/InvalidPixelFormatException.cs @@ -20,6 +20,7 @@ namespace System.Drawing.IconLib.Exceptions { [Author("Franco, Gustavo")] + [Serializable] public class InvalidPixelFormatException : Exception { #region Constructors diff --git a/iconlib_src/IconLib/System/Drawing/IconLib/IconImage.cs b/iconlib_src/IconLib/System/Drawing/IconLib/IconImage.cs index f9632a0..51ae803 100644 --- a/iconlib_src/IconLib/System/Drawing/IconLib/IconImage.cs +++ b/iconlib_src/IconLib/System/Drawing/IconLib/IconImage.cs @@ -22,6 +22,7 @@ using System.Drawing.Imaging; using System.Collections.Generic; using System.Runtime.InteropServices; +using System.Security.Permissions; using System.Drawing.IconLib.Exceptions; using System.Drawing.IconLib.BitmapEncoders; using System.Drawing.IconLib.EncodingFormats; @@ -95,13 +96,19 @@ public Icon Icon public unsafe Bitmap Transparent { - get {return Icon.ToBitmap();} + get + { + using (Icon icon = Icon) + return icon.ToBitmap(); + } } public Bitmap Image { get { + new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand(); + IntPtr hDCScreen = Win32.GetDC(IntPtr.Zero); // Image @@ -109,7 +116,7 @@ public Bitmap Image IntPtr bits; bitmapInfo.icHeader = mEncoder.Header; bitmapInfo.icHeader.biHeight /= 2; - bitmapInfo.icColors = Tools.StandarizePalette(mEncoder.Colors); + bitmapInfo.icColors = Tools.StandardizePalette(mEncoder.Colors); IntPtr hDCScreenOUTBmp = Win32.CreateCompatibleDC(hDCScreen); IntPtr hBitmapOUTBmp = Win32.CreateDIBSection(hDCScreenOUTBmp, ref bitmapInfo, 0, out bits, IntPtr.Zero, 0); Marshal.Copy(mEncoder.XOR, 0, bits, mEncoder.XOR.Length); @@ -140,6 +147,8 @@ public Bitmap Mask { get { + new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand(); + IntPtr hDCScreen = Win32.GetDC(IntPtr.Zero); // Image @@ -208,7 +217,7 @@ internal unsafe ICONDIRENTRY ICONDIRENTRY { ICONDIRENTRY iconDirEntry; iconDirEntry.bColorCount = (byte) mEncoder.Header.biClrUsed; - iconDirEntry.bHeight = (byte) mEncoder.Header.biHeight; + iconDirEntry.bHeight = (byte) (mEncoder.Header.biHeight / 2); iconDirEntry.bReserved = 0; iconDirEntry.bWidth = (byte) mEncoder.Header.biWidth; iconDirEntry.dwBytesInRes = (uint) (sizeof(BITMAPINFOHEADER) + @@ -227,7 +236,7 @@ internal unsafe GRPICONDIRENTRY GRPICONDIRENTRY { GRPICONDIRENTRY groupIconDirEntry; groupIconDirEntry.bColorCount = (byte) mEncoder.Header.biClrUsed; - groupIconDirEntry.bHeight = (byte) mEncoder.Header.biHeight; + groupIconDirEntry.bHeight = (byte) (mEncoder.Header.biHeight / 2); groupIconDirEntry.bReserved = 0; groupIconDirEntry.bWidth = (byte) mEncoder.Header.biWidth; groupIconDirEntry.dwBytesInRes = (uint) IconImageSize; @@ -242,6 +251,8 @@ internal unsafe GRPICONDIRENTRY GRPICONDIRENTRY #region Methods public unsafe void Set(Bitmap bitmap, Bitmap bitmapMask, Color transparentColor) { + new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand(); + // We need to rotate the images, but we don't want to mess with the source image, lets create a clone Bitmap image = (Bitmap) bitmap.Clone(); Bitmap mask = bitmapMask != null ? (Bitmap) bitmapMask.Clone() : null; diff --git a/iconlib_src/IconLib/System/Drawing/IconLib/LibraryFormats/IconFormat.cs b/iconlib_src/IconLib/System/Drawing/IconLib/LibraryFormats/IconFormat.cs index 3f5ce7a..072c946 100644 --- a/iconlib_src/IconLib/System/Drawing/IconLib/LibraryFormats/IconFormat.cs +++ b/iconlib_src/IconLib/System/Drawing/IconLib/LibraryFormats/IconFormat.cs @@ -21,6 +21,7 @@ using System.Text; using System.Collections.Generic; using System.Runtime.InteropServices; +using System.Security.Permissions; using System.Drawing.IconLib.Exceptions; namespace System.Drawing.IconLib.EncodingFormats @@ -81,6 +82,8 @@ public unsafe MultiIcon Load(Stream stream) public unsafe void Save(MultiIcon multiIcon, Stream stream) { + new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand(); + if (multiIcon.SelectedIndex == -1) return; diff --git a/iconlib_src/IconLib/System/Drawing/IconLib/LibraryFormats/NEFormat.cs b/iconlib_src/IconLib/System/Drawing/IconLib/LibraryFormats/NEFormat.cs index a5e0b9f..05cd6e0 100644 --- a/iconlib_src/IconLib/System/Drawing/IconLib/LibraryFormats/NEFormat.cs +++ b/iconlib_src/IconLib/System/Drawing/IconLib/LibraryFormats/NEFormat.cs @@ -22,6 +22,7 @@ using System.Drawing; using System.Collections.Generic; using System.Runtime.InteropServices; +using System.Security.Permissions; using System.Drawing.IconLib.Exceptions; @@ -124,6 +125,8 @@ public MultiIcon Load(Stream stream) public unsafe void Save(MultiIcon multiIcon, Stream stream) { + new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand(); + //Lets prepare the complete file in memory, then we dump everything to a file IMAGE_DOS_HEADER dos_header = new IMAGE_DOS_HEADER(); IMAGE_OS2_HEADER os2_header = new IMAGE_OS2_HEADER(); diff --git a/iconlib_src/IconLib/System/Drawing/IconLib/LibraryFormats/PEFormat.cs b/iconlib_src/IconLib/System/Drawing/IconLib/LibraryFormats/PEFormat.cs index d6ea2ca..b20cfaa 100644 --- a/iconlib_src/IconLib/System/Drawing/IconLib/LibraryFormats/PEFormat.cs +++ b/iconlib_src/IconLib/System/Drawing/IconLib/LibraryFormats/PEFormat.cs @@ -24,7 +24,7 @@ using System.Drawing.IconLib.Exceptions; using System.Drawing.Imaging; using System.Collections; -using System.Drawing.IconLIb; +using System.Drawing.IconLib; namespace System.Drawing.IconLib.EncodingFormats { @@ -33,6 +33,7 @@ internal class PEFormat : ILibraryFormat { #region Variables Declaration private static List mIconsIDs; + private object lockObj = new object(); #endregion #region Methods @@ -82,7 +83,8 @@ public unsafe MultiIcon Load(Stream stream) throw new InvalidFileException(); List iconsIDs; - lock (typeof(PEFormat)) + //lock (typeof(PEFormat)) + lock (lockObj) { mIconsIDs = new List(); bool bResult = Win32.EnumResourceNames(hLib, (IntPtr) ResourceType.RT_GROUP_ICON, new Win32.EnumResNameProc(EnumResNameProc), IntPtr.Zero); @@ -100,7 +102,7 @@ public unsafe MultiIcon Load(Stream stream) IntPtr hRsrc = IntPtr.Zero; if (Win32.IS_INTRESOURCE(id)) - hRsrc = Win32.FindResource(hLib, int.Parse(id), (IntPtr) ResourceType.RT_GROUP_ICON); + hRsrc = Win32.FindResource(hLib, (IntPtr)int.Parse(id), (IntPtr) ResourceType.RT_GROUP_ICON); else hRsrc = Win32.FindResource(hLib, id, (IntPtr) ResourceType.RT_GROUP_ICON); @@ -204,7 +206,7 @@ public unsafe void Save(MultiIcon multiIcon, Stream stream) buffer = ms.GetBuffer(); // Update resource but it doesn't write to disk yet - bResult = Win32.UpdateResource(updPtr, (int) ResourceType.RT_ICON, iconIndex, 0, buffer, (uint) ms.Length); + bResult = Win32.UpdateResource(updPtr, (IntPtr) ResourceType.RT_ICON, (IntPtr)iconIndex, 0, buffer, (uint) ms.Length); iconIndex++; @@ -230,13 +232,13 @@ public unsafe void Save(MultiIcon multiIcon, Stream stream) if (int.TryParse(singleIcon.Name, out id)) { // Write id as an integer - bResult = Win32.UpdateResource(updPtr, (int) ResourceType.RT_GROUP_ICON, (IntPtr) id, 0, buffer, (uint) ms.Length); + bResult = Win32.UpdateResource(updPtr, (IntPtr) ResourceType.RT_GROUP_ICON, (IntPtr) id, 0, buffer, (uint) ms.Length); } else { // Write id as string IntPtr pName = Marshal.StringToHGlobalAnsi(singleIcon.Name.ToUpper()); - bResult = Win32.UpdateResource(updPtr, (int) ResourceType.RT_GROUP_ICON, pName, 0, buffer, (uint) ms.Length); + bResult = Win32.UpdateResource(updPtr, (IntPtr) ResourceType.RT_GROUP_ICON, pName, 0, buffer, (uint) ms.Length); Marshal.FreeHGlobal(pName); } } diff --git a/iconlib_src/IconLib/System/Drawing/IconLib/MultiIcon.cs b/iconlib_src/IconLib/System/Drawing/IconLib/MultiIcon.cs index b675574..f2cdd0e 100644 --- a/iconlib_src/IconLib/System/Drawing/IconLib/MultiIcon.cs +++ b/iconlib_src/IconLib/System/Drawing/IconLib/MultiIcon.cs @@ -22,6 +22,7 @@ using System.Collections; using System.Collections.Generic; using System.Runtime.InteropServices; +using System.Security.Permissions; using System.Drawing.IconLib.Exceptions; using System.Drawing.IconLib.EncodingFormats; @@ -225,6 +226,8 @@ public void Save(string fileName, MultiIconFormat format) public void Save(Stream stream, MultiIconFormat format) { + new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand(); + switch (format) { case MultiIconFormat.ICO: diff --git a/iconlib_src/IconLib/System/Drawing/IconLib/Resource.Designer.cs b/iconlib_src/IconLib/System/Drawing/IconLib/Resource.Designer.cs index 834acc4..5da07f9 100644 --- a/iconlib_src/IconLib/System/Drawing/IconLib/Resource.Designer.cs +++ b/iconlib_src/IconLib/System/Drawing/IconLib/Resource.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.42 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -19,7 +19,7 @@ namespace System.Drawing.IconLib { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resource { @@ -39,7 +39,7 @@ internal Resource() { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("IconLib.System.Drawing.IconLib.Resource", typeof(Resource).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("System.Drawing.IconLib.Resource", typeof(Resource).Assembly); resourceMan = temp; } return resourceMan; @@ -60,6 +60,9 @@ internal Resource() { } } + /// + /// Looks up a localized resource of type System.Byte[]. + /// internal static byte[] EmptyDll { get { object obj = ResourceManager.GetObject("EmptyDll", resourceCulture); diff --git a/iconlib_src/IconLib/System/Drawing/IconLib/SingleIcon.cs b/iconlib_src/IconLib/System/Drawing/IconLib/SingleIcon.cs index 856c937..c107326 100644 --- a/iconlib_src/IconLib/System/Drawing/IconLib/SingleIcon.cs +++ b/iconlib_src/IconLib/System/Drawing/IconLib/SingleIcon.cs @@ -192,8 +192,11 @@ public IconImage Add(Icon icon) // then make them XP format Icons if (Tools.BitsFromPixelFormat(XORImage.PixelFormat) == 16) { - XORImage.Dispose(); - ANDImage.Dispose(); + //XORImage.Dispose(); + //XORImage = null; + //ANDImage.Dispose(); + //ANDImage = null; + //above commented code is done in finally block return Add(icon.ToBitmap(), Color.Transparent); } @@ -381,8 +384,10 @@ public IconImage this[int index] public struct Enumerator : IEnumerator, IDisposable, IEnumerator { #region Variables Declaration + [NonSerialized] private SingleIcon mList; private int mIndex; + [NonSerialized] private IconImage mCurrent; #endregion diff --git a/iconlib_src/IconLib/System/Drawing/IconLib/Structs.cs b/iconlib_src/IconLib/System/Drawing/IconLib/Structs.cs index 3c7a12c..f2530c2 100644 --- a/iconlib_src/IconLib/System/Drawing/IconLib/Structs.cs +++ b/iconlib_src/IconLib/System/Drawing/IconLib/Structs.cs @@ -21,6 +21,7 @@ using System.Text; using System.Collections.Generic; using System.Runtime.InteropServices; +using System.Security.Permissions; namespace System.Drawing.IconLib { @@ -392,6 +393,8 @@ public void Read(Stream stream) public unsafe void Write(Stream stream) { + new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand(); + BinaryWriter br = new BinaryWriter(stream); br.Write(rscAlignShift); diff --git a/iconlib_src/IconLib/System/Drawing/IconLib/Tools.cs b/iconlib_src/IconLib/System/Drawing/IconLib/Tools.cs index 05e5817..39c6b69 100644 --- a/iconlib_src/IconLib/System/Drawing/IconLib/Tools.cs +++ b/iconlib_src/IconLib/System/Drawing/IconLib/Tools.cs @@ -59,7 +59,7 @@ public static unsafe void FlipYBitmap(Bitmap bitmap) bitmap.UnlockBits(bitmapData); } - public static RGBQUAD[] StandarizePalette(RGBQUAD[] palette) + public static RGBQUAD[] StandardizePalette(RGBQUAD[] palette) { RGBQUAD[] newPalette = new RGBQUAD[256]; for(int i=0; i + + Debug + AnyCPU + 8.0.50727 + 2.0 + {4E4CFADE-E3EC-48CB-B526-B44BF95D76FE} + WinExe + Properties + MultiIconTester + MultiIcon + + + + + + + + + video.ico + v4.0 + + + + + 2.0 + + + + true + full + false + bin4\Debug\ + DEBUG;TRACE + prompt + 4 + true + + + pdbonly + true + bin4\Release\ + TRACE + prompt + 4 + true + + + + + + + + + + + + Form + + + Form1.cs + + + Form + + + Form2.cs + + + + + Designer + Form1.cs + + + Designer + Form2.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + {B8893240-CA7C-4AE9-A1BF-A32D080EFBD6} + IconLib + + + + + + + + \ No newline at end of file diff --git a/iconlib_src/MultiIcon/MultiIcon.Net4.sln b/iconlib_src/MultiIcon/MultiIcon.Net4.sln new file mode 100644 index 0000000..a33070f --- /dev/null +++ b/iconlib_src/MultiIcon/MultiIcon.Net4.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27703.2026 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MultiIcon", "MultiIcon.Net4.csproj", "{4E4CFADE-E3EC-48CB-B526-B44BF95D76FE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IconLib", "..\IconLib\IconLib.Net4.csproj", "{B8893240-CA7C-4AE9-A1BF-A32D080EFBD6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4E4CFADE-E3EC-48CB-B526-B44BF95D76FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4E4CFADE-E3EC-48CB-B526-B44BF95D76FE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4E4CFADE-E3EC-48CB-B526-B44BF95D76FE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4E4CFADE-E3EC-48CB-B526-B44BF95D76FE}.Release|Any CPU.Build.0 = Release|Any CPU + {B8893240-CA7C-4AE9-A1BF-A32D080EFBD6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B8893240-CA7C-4AE9-A1BF-A32D080EFBD6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B8893240-CA7C-4AE9-A1BF-A32D080EFBD6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B8893240-CA7C-4AE9-A1BF-A32D080EFBD6}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {82EC0920-4A01-4BFD-97A8-2CDEBB1F258F} + EndGlobalSection +EndGlobal diff --git a/iconlib_src/MultiIcon/MultiIcon.csproj b/iconlib_src/MultiIcon/MultiIcon.csproj index 3f1795b..52160da 100644 --- a/iconlib_src/MultiIcon/MultiIcon.csproj +++ b/iconlib_src/MultiIcon/MultiIcon.csproj @@ -1,4 +1,4 @@ - + Debug AnyCPU @@ -18,6 +18,12 @@ video.ico + v2.0 + + + + + 2.0 true diff --git a/iconlib_src/MultiIcon/MultiIcon.sln b/iconlib_src/MultiIcon/MultiIcon.sln index c287bab..0edccb8 100644 --- a/iconlib_src/MultiIcon/MultiIcon.sln +++ b/iconlib_src/MultiIcon/MultiIcon.sln @@ -1,6 +1,8 @@  -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27703.2026 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MultiIcon", "MultiIcon.csproj", "{BE1ADD60-F285-4084-BDCE-3C44CB076F58}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IconLib", "..\IconLib\IconLib.csproj", "{CE53747F-D2E6-4E1E-9EF4-A0AE02671B1D}" @@ -23,4 +25,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {82EC0920-4A01-4BFD-97A8-2CDEBB1F258F} + EndGlobalSection EndGlobal diff --git a/iconlib_src/MultiIcon/Properties/Resources.Designer.cs b/iconlib_src/MultiIcon/Properties/Resources.Designer.cs index 1fdc9ec..f669517 100644 --- a/iconlib_src/MultiIcon/Properties/Resources.Designer.cs +++ b/iconlib_src/MultiIcon/Properties/Resources.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.42 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -19,7 +19,7 @@ namespace MultiIconTester.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { diff --git a/iconlib_src/MultiIcon/Properties/Settings.Designer.cs b/iconlib_src/MultiIcon/Properties/Settings.Designer.cs index efb3d53..a46f2de 100644 --- a/iconlib_src/MultiIcon/Properties/Settings.Designer.cs +++ b/iconlib_src/MultiIcon/Properties/Settings.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.42 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -12,7 +12,7 @@ namespace MultiIconTester.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));