diff --git a/sources/tools/Stride.TextureConverter/Backend/Wrappers/FINetWrapper/FreeImageStaticImports.cs b/sources/tools/Stride.TextureConverter/Backend/Wrappers/FINetWrapper/FreeImageStaticImports.cs index 976e1cd9f3..1796258b97 100644 --- a/sources/tools/Stride.TextureConverter/Backend/Wrappers/FINetWrapper/FreeImageStaticImports.cs +++ b/sources/tools/Stride.TextureConverter/Backend/Wrappers/FINetWrapper/FreeImageStaticImports.cs @@ -303,7 +303,7 @@ internal static extern FIBITMAP AllocateExT(FREE_IMAGE_TYPE type, int width, int /// Flags to enable or disable plugin-features. /// Handle to a FreeImage bitmap. [DllImport(FreeImageLibrary, CharSet = CharSet.Auto, EntryPoint = "FreeImage_Load")] - public static extern FIBITMAP Load(FREE_IMAGE_FORMAT fif, string filename, FREE_IMAGE_LOAD_FLAGS flags); + private static extern FIBITMAP LoadNU(FREE_IMAGE_FORMAT fif, string filename, FREE_IMAGE_LOAD_FLAGS flags); /// /// Decodes a bitmap, allocates memory for it and returns it as a FIBITMAP. @@ -316,6 +316,11 @@ internal static extern FIBITMAP AllocateExT(FREE_IMAGE_TYPE type, int width, int [DllImport(FreeImageLibrary, CharSet = CharSet.Unicode, EntryPoint = "FreeImage_LoadU")] private static extern FIBITMAP LoadU(FREE_IMAGE_FORMAT fif, string filename, FREE_IMAGE_LOAD_FLAGS flags); + public static FIBITMAP Load(FREE_IMAGE_FORMAT fif, string filename, FREE_IMAGE_LOAD_FLAGS flags) + { + return OperatingSystem.IsWindows() ? LoadU(fif, filename, flags) : LoadNU(fif, filename, flags); + } + /// /// Loads a bitmap from an arbitrary source. /// @@ -336,7 +341,7 @@ internal static extern FIBITMAP AllocateExT(FREE_IMAGE_TYPE type, int width, int /// Flags to enable or disable plugin-features. /// Returns true on success, false on failure. [DllImport(FreeImageLibrary, CharSet = CharSet.Unicode, EntryPoint = "FreeImage_SaveU")] - public static extern bool Save(FREE_IMAGE_FORMAT fif, FIBITMAP dib, string filename, FREE_IMAGE_SAVE_FLAGS flags); + private static extern bool SaveNU(FREE_IMAGE_FORMAT fif, FIBITMAP dib, string filename, FREE_IMAGE_SAVE_FLAGS flags); /// /// Saves a previosly loaded FIBITMAP to a file. @@ -349,6 +354,11 @@ internal static extern FIBITMAP AllocateExT(FREE_IMAGE_TYPE type, int width, int /// Returns true on success, false on failure. [DllImport(FreeImageLibrary, CharSet = CharSet.Unicode, EntryPoint = "FreeImage_SaveU")] private static extern bool SaveU(FREE_IMAGE_FORMAT fif, FIBITMAP dib, string filename, FREE_IMAGE_SAVE_FLAGS flags); + + public static bool Save(FREE_IMAGE_FORMAT fif, FIBITMAP dib, string filename, FREE_IMAGE_SAVE_FLAGS flags) + { + return OperatingSystem.IsWindows() ? SaveU(fif, dib, filename, flags) : SaveNU(fif, dib, filename, flags); + } /// /// Saves a bitmap to an arbitrary source. @@ -597,7 +607,7 @@ public static extern FREE_IMAGE_FORMAT RegisterExternalPlugin(string path, /// The filename or -extension. /// The of the plugin. [DllImport(FreeImageLibrary, CharSet = CharSet.Auto, EntryPoint = "FreeImage_GetFIFFromFilename")] - public static extern FREE_IMAGE_FORMAT GetFIFFromFilename(string filename); + private static extern FREE_IMAGE_FORMAT GetFIFFromFilenameNU(string filename); /// /// This function takes a filename or a file-extension and returns the plugin that can @@ -609,6 +619,11 @@ public static extern FREE_IMAGE_FORMAT RegisterExternalPlugin(string path, [DllImport(FreeImageLibrary, CharSet = CharSet.Unicode, EntryPoint = "FreeImage_GetFIFFromFilenameU")] public static extern FREE_IMAGE_FORMAT GetFIFFromFilenameU(string filename); + public static FREE_IMAGE_FORMAT GetFIFFromFilename(string filename) + { + return OperatingSystem.IsWindows() ? GetFIFFromFilenameU(filename) : GetFIFFromFilenameNU(filename); + } + /// /// Checks if a plugin can load bitmaps. /// @@ -786,7 +801,7 @@ public static extern FIMULTIBITMAP OpenMultiBitmapFromHandle(FREE_IMAGE_FORMAT f /// Reserved parameter - use 0. /// Type of the bitmap. [DllImport(FreeImageLibrary, CharSet = CharSet.Auto, EntryPoint = "FreeImage_GetFileType")] - public static extern FREE_IMAGE_FORMAT GetFileType(string filename, int size); + private static extern FREE_IMAGE_FORMAT GetFileTypeNU(string filename, int size); /// @@ -799,6 +814,11 @@ public static extern FIMULTIBITMAP OpenMultiBitmapFromHandle(FREE_IMAGE_FORMAT f [DllImport(FreeImageLibrary, CharSet = CharSet.Unicode, EntryPoint = "FreeImage_GetFileTypeU")] public static extern FREE_IMAGE_FORMAT GetFileTypeU(string filename, int size); + public static FREE_IMAGE_FORMAT GetFileType(string filename, int size) + { + return OperatingSystem.IsWindows() ? GetFIFFromFilenameU(filename) : GetFIFFromFilenameNU(filename); + } + /// /// Uses the structure as described in the topic bitmap management functions /// to identify a bitmap type.