Skip to content
Merged
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
15 changes: 15 additions & 0 deletions build/Stride.sln
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stride.Importer.3D", "..\so
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stride.BepuPhysics.Tests", "..\sources\engine\Stride.BepuPhysics\Stride.BepuPhysics.Tests\Stride.BepuPhysics.Tests.csproj", "{7B70C783-4085-4702-B3C6-6570FD85CB8F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stride.FreeImage", "..\sources\tools\Stride.FreeImage\Stride.FreeImage.csproj", "{03695F9B-10E9-4A10-93AE-6402E46F10B5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1523,6 +1525,18 @@ Global
{7B70C783-4085-4702-B3C6-6570FD85CB8F}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{7B70C783-4085-4702-B3C6-6570FD85CB8F}.Release|Win32.ActiveCfg = Release|Any CPU
{7B70C783-4085-4702-B3C6-6570FD85CB8F}.Release|Win32.Build.0 = Release|Any CPU
{03695F9B-10E9-4A10-93AE-6402E46F10B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{03695F9B-10E9-4A10-93AE-6402E46F10B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{03695F9B-10E9-4A10-93AE-6402E46F10B5}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{03695F9B-10E9-4A10-93AE-6402E46F10B5}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{03695F9B-10E9-4A10-93AE-6402E46F10B5}.Debug|Win32.ActiveCfg = Debug|Any CPU
{03695F9B-10E9-4A10-93AE-6402E46F10B5}.Debug|Win32.Build.0 = Debug|Any CPU
{03695F9B-10E9-4A10-93AE-6402E46F10B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{03695F9B-10E9-4A10-93AE-6402E46F10B5}.Release|Any CPU.Build.0 = Release|Any CPU
{03695F9B-10E9-4A10-93AE-6402E46F10B5}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{03695F9B-10E9-4A10-93AE-6402E46F10B5}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{03695F9B-10E9-4A10-93AE-6402E46F10B5}.Release|Win32.ActiveCfg = Release|Any CPU
{03695F9B-10E9-4A10-93AE-6402E46F10B5}.Release|Win32.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1651,6 +1665,7 @@ Global
{7715D094-DF59-4D91-BC9A-9A5118039ECB} = {DE048114-9AE4-467E-A879-188DC0D88A59}
{66EFFDE4-24F0-4E57-9618-0F5577E20A1E} = {6F473FA6-4F8B-4FBA-AE33-EE5AF997D50C}
{7B70C783-4085-4702-B3C6-6570FD85CB8F} = {DE048114-9AE4-467E-A879-188DC0D88A59}
{03695F9B-10E9-4A10-93AE-6402E46F10B5} = {1AE1AC60-5D2F-4CA7-AE20-888F44551185}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FF877973-604D-4EA7-B5F5-A129961F9EF2}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
using FreeImageAPI.IO;
using FreeImageAPI.Metadata;
using Stride.Core;
using StridePixelFormat = Stride.Graphics.PixelFormat;

namespace FreeImageAPI
{
Expand Down Expand Up @@ -2423,165 +2422,6 @@ public static bool GetFormatParameters(
return result;
}

/// <summary>
/// Retrieves all parameters needed to create a new FreeImage bitmap from the pixel format.
/// </summary>
/// <param name="format">The <see cref="Stride.Graphics.PixelFormat"/> of the image.</param>
/// <param name="type">Returns the type used for the new bitmap.</param>
/// <param name="bpp">Returns the color depth for the new bitmap.</param>
/// <param name="redMask">Returns the red_mask for the new bitmap.</param>
/// <param name="greenMask">Returns the green_mask for the new bitmap.</param>
/// <param name="blueMask">Returns the blue_mask for the new bitmap.</param>
/// <returns>True in case a matching conversion exists; else false.
/// </returns>
public static bool GetFormatParameters(
StridePixelFormat format,
out FREE_IMAGE_TYPE type,
out uint bpp,
out uint redMask,
out uint greenMask,
out uint blueMask)
{
var result = true;
type = FREE_IMAGE_TYPE.FIT_UNKNOWN;
bpp = 0;
redMask = 0;
greenMask = 0;
blueMask = 0;

switch (format)
{
case StridePixelFormat.R32G32B32A32_Float:
type = FREE_IMAGE_TYPE.FIT_RGBAF;
bpp = 128;
break;
case StridePixelFormat.R32G32B32_Float:
type = FREE_IMAGE_TYPE.FIT_RGBF;
bpp = 96;
break;
case StridePixelFormat.R16G16B16A16_Typeless:
case StridePixelFormat.R16G16B16A16_Float:
case StridePixelFormat.R16G16B16A16_UNorm:
case StridePixelFormat.R16G16B16A16_UInt:
case StridePixelFormat.R16G16B16A16_SNorm:
case StridePixelFormat.R16G16B16A16_SInt:
type = FREE_IMAGE_TYPE.FIT_RGBA16;
bpp = 64;
break;
case StridePixelFormat.D32_Float:
case StridePixelFormat.R32_Float:
type = FREE_IMAGE_TYPE.FIT_FLOAT;
bpp = 32;
break;
case StridePixelFormat.R32_SInt:
type = FREE_IMAGE_TYPE.FIT_INT32;
bpp = 32;
break;
case StridePixelFormat.R32_UInt:
type = FREE_IMAGE_TYPE.FIT_UINT32;
bpp = 32;
break;
case StridePixelFormat.R16_SInt:
type = FREE_IMAGE_TYPE.FIT_INT16;
bpp = 16;
break;
case StridePixelFormat.R16_UInt:
type = FREE_IMAGE_TYPE.FIT_UINT16;
bpp = 16;
break;
case StridePixelFormat.R32_Typeless:
type = FREE_IMAGE_TYPE.FIT_BITMAP;
bpp = 32;
break;
case StridePixelFormat.R8G8B8A8_Typeless:
case StridePixelFormat.R8G8B8A8_UNorm:
case StridePixelFormat.R8G8B8A8_UNorm_SRgb:
case StridePixelFormat.R8G8B8A8_UInt:
case StridePixelFormat.R8G8B8A8_SNorm:
case StridePixelFormat.R8G8B8A8_SInt:
type = FREE_IMAGE_TYPE.FIT_BITMAP;
bpp = 32;
redMask = FI_RGBA_RED_MASK;
greenMask = FI_RGBA_GREEN_MASK;
blueMask = FI_RGBA_BLUE_MASK;
break;
case StridePixelFormat.R16G16_Typeless:
case StridePixelFormat.R16G16_Float:
case StridePixelFormat.R16G16_UNorm:
case StridePixelFormat.R16G16_UInt:
case StridePixelFormat.R16G16_SNorm:
case StridePixelFormat.R16G16_SInt:
type = FREE_IMAGE_TYPE.FIT_BITMAP;
bpp = 32;
redMask = 0xFFFF0000;
greenMask = 0x0000FFFF;
break;
case StridePixelFormat.B8G8R8A8_Typeless:
case StridePixelFormat.B8G8R8A8_UNorm_SRgb:
case StridePixelFormat.B8G8R8X8_Typeless:
case StridePixelFormat.B8G8R8X8_UNorm_SRgb:
case StridePixelFormat.B8G8R8A8_UNorm:
case StridePixelFormat.B8G8R8X8_UNorm:
type = FREE_IMAGE_TYPE.FIT_BITMAP;
bpp = 32;
redMask = FI_RGBA_BLUE_MASK;
greenMask = FI_RGBA_GREEN_MASK;
blueMask = FI_RGBA_RED_MASK;
break;

case StridePixelFormat.B5G6R5_UNorm:
type = FREE_IMAGE_TYPE.FIT_BITMAP;
bpp = 16;
redMask = FI16_565_RED_MASK;
greenMask = FI16_565_GREEN_MASK;
blueMask = FI16_565_BLUE_MASK;
break;
case StridePixelFormat.B5G5R5A1_UNorm:
type = FREE_IMAGE_TYPE.FIT_BITMAP;
bpp = 16;
redMask = FI16_555_RED_MASK;
greenMask = FI16_555_GREEN_MASK;
blueMask = FI16_555_BLUE_MASK;
break;
case StridePixelFormat.R16_Typeless:
case StridePixelFormat.R16_Float:
case StridePixelFormat.D16_UNorm:
case StridePixelFormat.R16_UNorm:
case StridePixelFormat.R16_SNorm:
type = FREE_IMAGE_TYPE.FIT_UINT16;
bpp = 16;
break;
case StridePixelFormat.R8G8_Typeless:
case StridePixelFormat.R8G8_UNorm:
case StridePixelFormat.R8G8_UInt:
case StridePixelFormat.R8G8_SNorm:
case StridePixelFormat.R8G8_SInt:
type = FREE_IMAGE_TYPE.FIT_BITMAP;
bpp = 16;
redMask = 0xFF00;
greenMask= 0x00FF;
break;
case StridePixelFormat.R8_Typeless:
case StridePixelFormat.R8_UNorm:
case StridePixelFormat.R8_UInt:
case StridePixelFormat.R8_SNorm:
case StridePixelFormat.R8_SInt:
case StridePixelFormat.A8_UNorm:
type = FREE_IMAGE_TYPE.FIT_BITMAP;
bpp = 8;
break;
case StridePixelFormat.R1_UNorm:
type = FREE_IMAGE_TYPE.FIT_BITMAP;
bpp = 1;
break;
default:
result = false;
break;
}

return result;
}

/// <summary>
/// Retrieves all parameters needed to create a new FreeImage bitmap from
/// raw bits <see cref="System.Drawing.Image"/>.
Expand Down
5 changes: 5 additions & 0 deletions sources/tools/Stride.FreeImage/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using System.Runtime.CompilerServices;

#pragma warning disable 436 // Stride.PublicKeys is defined in multiple assemblies

[assembly: InternalsVisibleTo("Stride.TextureConverter")]
20 changes: 20 additions & 0 deletions sources/tools/Stride.FreeImage/Stride.FreeImage.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project>
<Import Project="..\..\targets\Stride.props" />
<PropertyGroup>
<TargetFramework>$(StrideXplatEditorTargetFramework)</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<StrideNativeLib Include="$(MSBuildThisFileDirectory)..\..\..\deps\FreeImage\Release\**\*.dll">
<Link>runtimes\%(RecursiveDir)native\%(Filename)%(Extension)</Link>
</StrideNativeLib>
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Drawing.Common" Condition="'$(TargetFramework)' == '$(StrideFramework)'" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\core\Stride.Core\Stride.Core.csproj" />
</ItemGroup>
<Import Project="$(StrideSdkTargets)" />
</Project>
Loading
Loading