diff --git a/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_01_dither.tif b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_01_dither.tif new file mode 100644 index 0000000..05e52a7 Binary files /dev/null and b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_01_dither.tif differ diff --git a/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_01_threshold.tif b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_01_threshold.tif new file mode 100644 index 0000000..4ca4181 Binary files /dev/null and b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_01_threshold.tif differ diff --git a/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_04.tif b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_04.tif new file mode 100644 index 0000000..b905a74 Binary files /dev/null and b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_04.tif differ diff --git a/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_04_gs_minisblack.tif b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_04_gs_minisblack.tif new file mode 100644 index 0000000..7b37c6b Binary files /dev/null and b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_04_gs_minisblack.tif differ diff --git a/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_04_gs_unordered.tif b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_04_gs_unordered.tif new file mode 100644 index 0000000..2106f53 Binary files /dev/null and b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_04_gs_unordered.tif differ diff --git a/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_08.tif b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_08.tif new file mode 100644 index 0000000..cb5471a Binary files /dev/null and b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_08.tif differ diff --git a/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_08_gs_minisblack.tif b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_08_gs_minisblack.tif new file mode 100644 index 0000000..3bb62a2 Binary files /dev/null and b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_08_gs_minisblack.tif differ diff --git a/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_08_gs_unordered.tif b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_08_gs_unordered.tif new file mode 100644 index 0000000..c9acc05 Binary files /dev/null and b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_08_gs_unordered.tif differ diff --git a/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_16_555.bmp b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_16_555.bmp new file mode 100644 index 0000000..2b2e5ff Binary files /dev/null and b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_16_555.bmp differ diff --git a/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_16_565.bmp b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_16_565.bmp new file mode 100644 index 0000000..2d10896 Binary files /dev/null and b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_16_565.bmp differ diff --git a/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_24.tif b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_24.tif new file mode 100644 index 0000000..171c8d7 Binary files /dev/null and b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_24.tif differ diff --git a/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_32.tif b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_32.tif new file mode 100644 index 0000000..a1ecee2 Binary files /dev/null and b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_32.tif differ diff --git a/Wrapper/FreeImage.NET/cs/UnitTestData/Images/JPEG/Image.jpg b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/JPEG/Image.jpg new file mode 100644 index 0000000..df1918c Binary files /dev/null and b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/JPEG/Image.jpg differ diff --git a/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Metadata/exif.jpg b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Metadata/exif.jpg new file mode 100644 index 0000000..c9e425d Binary files /dev/null and b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Metadata/exif.jpg differ diff --git a/Wrapper/FreeImage.NET/cs/UnitTestData/Images/MultiPaged/Image.tif b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/MultiPaged/Image.tif new file mode 100644 index 0000000..3a755d0 Binary files /dev/null and b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/MultiPaged/Image.tif differ diff --git a/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_01_dither.tif b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_01_dither.tif new file mode 100644 index 0000000..3131f90 Binary files /dev/null and b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_01_dither.tif differ diff --git a/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_01_threshold.tif b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_01_threshold.tif new file mode 100644 index 0000000..67eb2cb Binary files /dev/null and b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_01_threshold.tif differ diff --git a/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_04.tif b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_04.tif new file mode 100644 index 0000000..051bbd0 Binary files /dev/null and b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_04.tif differ diff --git a/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_04_gs_minisblack.tif b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_04_gs_minisblack.tif new file mode 100644 index 0000000..4be9b36 Binary files /dev/null and b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_04_gs_minisblack.tif differ diff --git a/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_04_gs_unordered.tif b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_04_gs_unordered.tif new file mode 100644 index 0000000..87b3851 Binary files /dev/null and b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_04_gs_unordered.tif differ diff --git a/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_08.tif b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_08.tif new file mode 100644 index 0000000..2856369 Binary files /dev/null and b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_08.tif differ diff --git a/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_08_gs_minisblack.tif b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_08_gs_minisblack.tif new file mode 100644 index 0000000..a928267 Binary files /dev/null and b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_08_gs_minisblack.tif differ diff --git a/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_08_gs_unordered.tif b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_08_gs_unordered.tif new file mode 100644 index 0000000..ebc7fe2 Binary files /dev/null and b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_08_gs_unordered.tif differ diff --git a/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_16_555.bmp b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_16_555.bmp new file mode 100644 index 0000000..0432ac4 Binary files /dev/null and b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_16_555.bmp differ diff --git a/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_16_565.bmp b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_16_565.bmp new file mode 100644 index 0000000..0dfc527 Binary files /dev/null and b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_16_565.bmp differ diff --git a/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_24.tif b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_24.tif new file mode 100644 index 0000000..4b25041 Binary files /dev/null and b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_24.tif differ diff --git a/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Original_Even.bmp b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Original_Even.bmp new file mode 100644 index 0000000..fd0f2c9 Binary files /dev/null and b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Original_Even.bmp differ diff --git a/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Original_Odd.bmp b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Original_Odd.bmp new file mode 100644 index 0000000..d26cef6 Binary files /dev/null and b/Wrapper/FreeImage.NET/cs/UnitTestData/Images/Original_Odd.bmp differ diff --git a/Wrapper/FreeImage.NET/cs/UnitTestData/MarshallerBug/Bug.cs b/Wrapper/FreeImage.NET/cs/UnitTestData/MarshallerBug/Bug.cs new file mode 100644 index 0000000..99df560 --- /dev/null +++ b/Wrapper/FreeImage.NET/cs/UnitTestData/MarshallerBug/Bug.cs @@ -0,0 +1,153 @@ +// This sample code shows a bug in the .NET marshaller. +// Native C++ functions returning a string (char*) sometimes +// are not marshalled correctly throwing an exception. +// This is the reason why the .NET wrapper converts +// the char-pointer manually into a .NET string. + +using System; +using System.Text; +using System.Runtime.InteropServices; + +public static class FreeImage +{ + private const string dllName = "FreeImage.dll"; + + [DllImport(dllName, EntryPoint = "FreeImage_GetFormatFromFIF")] + [return: MarshalAs(UnmanagedType.LPStr)] + public static extern string GetFormatFromFIF(int format); + + [DllImport(dllName, EntryPoint = "FreeImage_GetFIFExtensionList")] + [return: MarshalAs(UnmanagedType.LPStr)] + public static extern string GetFIFExtensionList(int format); + + [DllImport(dllName, EntryPoint = "FreeImage_GetFIFDescription")] + [return: MarshalAs(UnmanagedType.LPStr)] + public static extern string GetFIFDescription(int format); + + [DllImport(dllName, EntryPoint = "FreeImage_GetFIFRegExpr")] + [return: MarshalAs(UnmanagedType.LPStr)] + public static extern string GetFIFRegExpr(int format); + + [DllImport(dllName, EntryPoint = "FreeImage_GetFIFMimeType")] + [return: MarshalAs(UnmanagedType.LPStr)] + public static extern string GetFIFMimeType(int format); + + [DllImport(dllName, EntryPoint = "FreeImage_GetFIFCount")] + public static extern int GetFIFCount(); +} + +public class Program +{ + public static bool[,] getmatrix(int fifCount) + { + bool[,] matrix = new bool[5, fifCount]; + + int j = 0; + + for (int i = 0; i < fifCount; i++) + { + bool success = true; + try + { + FreeImage.GetFormatFromFIF(i); + } + catch + { + success = false; + } + matrix[j, i] = success; + } + j++; + + for (int i = 0; i < fifCount; i++) + { + bool success = true; + try + { + FreeImage.GetFIFExtensionList(i); + } + catch + { + success = false; + } + matrix[j, i] = success; + } + j++; + + for (int i = 0; i < fifCount; i++) + { + bool success = true; + try + { + FreeImage.GetFIFDescription(i); + } + catch + { + success = false; + } + matrix[j, i] = success; + } + j++; + + for (int i = 0; i < fifCount; i++) + { + bool success = true; + try + { + FreeImage.GetFIFRegExpr(i); + } + catch + { + success = false; + } + matrix[j, i] = success; + } + j++; + + for (int i = 0; i < fifCount; i++) + { + bool success = true; + try + { + FreeImage.GetFIFMimeType(i); + } + catch + { + success = false; + } + matrix[j, i] = success; + } + + return matrix; + } + + public static void Main() + { + int fifCount = FreeImage.GetFIFCount(); + bool[,] matrix = getmatrix(fifCount); + + Console.Clear(); + Console.WriteLine("1: GetFormatFromFIF"); + Console.WriteLine("2: GetFIFExtensionList"); + Console.WriteLine("3: GetFIFDescription"); + Console.WriteLine("4: GetFIFRegExpr"); + Console.WriteLine("5: GetFIFMimeType"); + Console.Write(Environment.NewLine); + + Console.Write("FIF:\t"); + for (int x = 1; x < 6; x++) + Console.Write("{0}:\t", x); + + Console.Write(Environment.NewLine); + + for (int k = 0; k < fifCount; k++) + { + Console.Write("{0}:\t", k); + for (int l = 0; l < 5; l++) + { + Console.Write(matrix[l, k] ? "1\t" : "0\t"); + } + Console.Write(Environment.NewLine); + } + } +} \ No newline at end of file diff --git a/Wrapper/FreeImage.NET/cs/UnitTestData/NUnit.txt b/Wrapper/FreeImage.NET/cs/UnitTestData/NUnit.txt new file mode 100644 index 0000000..cca3df5 --- /dev/null +++ b/Wrapper/FreeImage.NET/cs/UnitTestData/NUnit.txt @@ -0,0 +1,14 @@ +NUnit 2.x is needed for FreeImage .NET wrapper unit tests. It can be +downloaded from http://www.nunit.org/ + +After installing NUnit, double click on the NUnit project file +FreeImage.NET.nunit located in the FreeImage .NET wrapper Source folder +to load the project. + +The FreeImage .NET wrapper unit test project UnitTest.csproj, located +under Source\UnitTest, must be compiled in 'Debug' mode prior to opening +the NUnit project. + +The FreeImage .NET wrapper unit test project UnitTest.csproj currently +relies on the FreeImage .NET wrapper single source file, created by the +Source File Merger, located in the Source\SourceFileMerger folder. \ No newline at end of file