Skip to content

Commit 0e280e0

Browse files
committed
fixup! refactor: Move FreeImage into separate project
1 parent 8d7fb4a commit 0e280e0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+28549
-28611
lines changed

sources/tools/Stride.FreeImage/Classes/FreeImageBitmap.cs

Lines changed: 3995 additions & 3996 deletions
Large diffs are not rendered by default.

sources/tools/Stride.FreeImage/Classes/FreeImageEngine.cs

Lines changed: 82 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -4,97 +4,96 @@
44
using System.Runtime.InteropServices;
55
using System.Diagnostics;
66

7-
namespace FreeImageAPI
7+
namespace FreeImageAPI;
8+
9+
/// <summary>
10+
/// Class handling non-bitmap related functions.
11+
/// </summary>
12+
public static class FreeImageEngine
813
{
9-
/// <summary>
10-
/// Class handling non-bitmap related functions.
11-
/// </summary>
12-
public static class FreeImageEngine
13-
{
14-
#region Callback
14+
#region Callback
15+
16+
// Callback delegate
17+
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
18+
private static readonly OutputMessageFunction outputMessageFunction;
1519

16-
// Callback delegate
17-
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
18-
private static readonly OutputMessageFunction outputMessageFunction;
20+
static FreeImageEngine()
21+
{
22+
// Check if FreeImage.dll is present and cancel setting the callbackfuntion if not
23+
if (!IsAvailable)
24+
{
25+
return;
26+
}
27+
// Create a delegate (function pointer) to 'OnMessage'
28+
outputMessageFunction = new OutputMessageFunction(OnMessage);
29+
// Set the callback
30+
FreeImage.SetOutputMessage(outputMessageFunction);
31+
}
1932

20-
static FreeImageEngine()
21-
{
22-
// Check if FreeImage.dll is present and cancel setting the callbackfuntion if not
23-
if (!IsAvailable)
24-
{
25-
return;
26-
}
27-
// Create a delegate (function pointer) to 'OnMessage'
28-
outputMessageFunction = new OutputMessageFunction(OnMessage);
29-
// Set the callback
30-
FreeImage.SetOutputMessage(outputMessageFunction);
31-
}
33+
/// <summary>
34+
/// Internal callback
35+
/// </summary>
36+
private static void OnMessage(FREE_IMAGE_FORMAT fif, string message)
37+
{
38+
// Get a local copy of the multicast-delegate
39+
OutputMessageFunction m = Message;
3240

33-
/// <summary>
34-
/// Internal callback
35-
/// </summary>
36-
private static void OnMessage(FREE_IMAGE_FORMAT fif, string message)
37-
{
38-
// Get a local copy of the multicast-delegate
39-
OutputMessageFunction m = Message;
41+
// Check the local copy instead of the static instance
42+
// to prevent a second thread from setting the delegate
43+
// to null, which would cause a nullreference exception
44+
// Invoke the multicast-delegate
45+
m?.Invoke(fif, message);
46+
}
4047

41-
// Check the local copy instead of the static instance
42-
// to prevent a second thread from setting the delegate
43-
// to null, which would cause a nullreference exception
44-
// Invoke the multicast-delegate
45-
m?.Invoke(fif, message);
48+
/// <summary>
49+
/// Gets a value indicating if the FreeImage DLL is available or not.
50+
/// </summary>
51+
public static bool IsAvailable
52+
{
53+
get
54+
{
55+
return FreeImage.IsAvailable();
4656
}
57+
}
4758

48-
/// <summary>
49-
/// Gets a value indicating if the FreeImage DLL is available or not.
50-
/// </summary>
51-
public static bool IsAvailable
52-
{
53-
get
54-
{
55-
return FreeImage.IsAvailable();
56-
}
57-
}
58-
59-
/// <summary>
60-
/// Internal errors in FreeImage generate a logstring that can be
61-
/// captured by this event.
62-
/// </summary>
63-
public static event OutputMessageFunction Message;
59+
/// <summary>
60+
/// Internal errors in FreeImage generate a logstring that can be
61+
/// captured by this event.
62+
/// </summary>
63+
public static event OutputMessageFunction Message;
6464

65-
#endregion
65+
#endregion
6666

67-
/// <summary>
68-
/// Gets a string containing the current version of the library.
69-
/// </summary>
70-
public static string Version
71-
{
72-
get
73-
{
74-
return FreeImage.GetVersion();
75-
}
76-
}
67+
/// <summary>
68+
/// Gets a string containing the current version of the library.
69+
/// </summary>
70+
public static string Version
71+
{
72+
get
73+
{
74+
return FreeImage.GetVersion();
75+
}
76+
}
7777

78-
/// <summary>
79-
/// Gets a string containing a standard copyright message.
80-
/// </summary>
81-
public static string CopyrightMessage
82-
{
83-
get
84-
{
85-
return FreeImage.GetCopyrightMessage();
86-
}
87-
}
78+
/// <summary>
79+
/// Gets a string containing a standard copyright message.
80+
/// </summary>
81+
public static string CopyrightMessage
82+
{
83+
get
84+
{
85+
return FreeImage.GetCopyrightMessage();
86+
}
87+
}
8888

89-
/// <summary>
90-
/// Gets whether the platform is using Little Endian.
91-
/// </summary>
92-
public static bool IsLittleEndian
93-
{
94-
get
95-
{
96-
return FreeImage.IsLittleEndian();
97-
}
98-
}
99-
}
100-
}
89+
/// <summary>
90+
/// Gets whether the platform is using Little Endian.
91+
/// </summary>
92+
public static bool IsLittleEndian
93+
{
94+
get
95+
{
96+
return FreeImage.IsLittleEndian();
97+
}
98+
}
99+
}

0 commit comments

Comments
 (0)