Skip to content

Commit

Permalink
Merge pull request #16 from Artomatix/1.1.0
Browse files Browse the repository at this point in the history
Updating to 1.1.0
  • Loading branch information
Colm Vize authored Mar 6, 2019
2 parents 547bc14 + 8b30ecc commit 916a6d2
Show file tree
Hide file tree
Showing 38 changed files with 2,736 additions and 1,899 deletions.
383 changes: 211 additions & 172 deletions bindings/csharp/ArtomatixImageLoader/ArtomatixImageLoader/AImg.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,130 +1,104 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
<ProjectGuid>{C0BB2915-8150-4817-9351-2B7F83D96F2A}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>Artomatix.ImageLoader</RootNamespace>
<AssemblyName>Artomatix.ImageLoader</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<ProductVersion>12.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<WarningLevel>4</WarningLevel>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<WarningLevel>4</WarningLevel>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.IO.Compression" />
</ItemGroup>
<ItemGroup>
<Compile Include="NativeFuncs.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Enums.cs" />
<Compile Include="AImg.cs" />
<Compile Include="ImgLoader.cs" />
<Compile Include="Exceptions.cs" />
<Compile Include="ImgEncodingOptions.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<None Include="native_code_setting.txt" />
</ItemGroup>
<PropertyGroup>
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="embedded_files\binaries.zip" />
</ItemGroup>
<Import Project="..\..\..\..\packages\NativeCodeBuilder\build\NativeCodeBuilder.targets" Condition="Exists('..\..\..\..\packages\NativeCodeBuilder\build\NativeCodeBuilder.targets')" />
<Import Project="..\..\..\..\.paket\paket.targets" />
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6'">
<ItemGroup>
<Reference Include="NativeBinaryManager">
<HintPath>..\..\..\..\packages\NativeBinaryManager\lib\NativeBinaryManager.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6'">
<ItemGroup>
<Reference Include="nunit.framework">
<HintPath>..\..\..\..\packages\NUnit\lib\nunit.framework.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6'">
<ItemGroup>
<Reference Include="Stugo.Interop">
<HintPath>..\..\..\..\packages\Stugo.Interop\lib\Stugo.Interop.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6'">
<ItemGroup>
<Reference Include="ZipStorer">
<HintPath>..\..\..\..\packages\ZipStorer\lib\net20\ZipStorer.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
<ProjectGuid>{C0BB2915-8150-4817-9351-2B7F83D96F2A}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>Artomatix.ImageLoader</RootNamespace>
<AssemblyName>Artomatix.ImageLoader</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<WarningLevel>4</WarningLevel>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.IO.Compression" />
</ItemGroup>
<ItemGroup>
<Compile Include="NativeFuncs.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Enums.cs" />
<Compile Include="AImg.cs" />
<Compile Include="ImgLoader.cs" />
<Compile Include="Exceptions.cs" />
<Compile Include="ImgEncodingOptions.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<EmbeddedResource Include="embedded_files\binaries.zip" />
</ItemGroup>
<Import Project="..\..\..\..\packages\NativeCodeBuilder\build\NativeCodeBuilder.targets" Condition="Exists('..\..\..\..\packages\NativeCodeBuilder\build\NativeCodeBuilder.targets')" />
<Target Name="AfterBuild">
<Exec Command="mkdir $(SolutionDir)../TempDLLs; cp $(ProjectDir)embedded_files/native_code_linux_x64 $(SolutionDir)../TempDLLs/AIMG.dll" Condition="$(OS) != 'Windows_NT'" />
<Exec Command="mkdir $(SolutionDir)..\TempDLLs" Condition="$(OS) == 'Windows_NT' And !Exists('$(SolutionDir)..\TempDLLs')" />
<Exec Command="copy /y $(ProjectDir)embedded_files\native_code_windows_x64 $(SolutionDir)..\TempDLLs\AIMG.dll" Condition="$(OS) == 'Windows_NT'" />
</Target>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6'">
<ItemGroup>
<Reference Include="NativeBinaryManager">
<HintPath>..\..\..\..\packages\NativeBinaryManager\lib\NativeBinaryManager.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6'">
<ItemGroup>
<Reference Include="nunit.framework">
<HintPath>..\..\..\..\packages\NUnit\lib\nunit.framework.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6'">
<ItemGroup>
<Reference Include="Stugo.Interop">
<HintPath>..\..\..\..\packages\Stugo.Interop\lib\Stugo.Interop.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6'">
<ItemGroup>
<Reference Include="ZipStorer">
<HintPath>..\..\..\..\packages\ZipStorer\lib\net452\ZipStorer.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
</Project>
54 changes: 34 additions & 20 deletions bindings/csharp/ArtomatixImageLoader/ArtomatixImageLoader/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,48 @@ public enum AImgFileFormat
PNG_IMAGE_FORMAT = 2,
JPEG_IMAGE_FORMAT = 3,
TGA_IMAGE_FORMAT = 4,
TIFF_IMAGE_FORMAT = 5
TIFF_IMAGE_FORMAT = 5,
HDR_IMAGE_FORMAT = 6
};

// format is [channels][bits per channel][U/F]
// U means unsigned normalised, so eg 8U maps integer vals 0-255 to float range 0-1, F means an normal float value

[Flags]
public enum AImgFormat
{
INVALID_FORMAT = -1,

R8U = 0,
RG8U = 1,
RGB8U = 2,
RGBA8U = 3,

R16U = 4,
RG16U = 5,
RGB16U = 6,
RGBA16U = 7,

R16F = 8,
RG16F = 9,
RGB16F = 10,
RGBA16F = 11,

R32F = 12,
RG32F = 13,
RGB32F = 14,
RGBA32F = 15
_8BITS = 1 << 0,
_16BITS = 1 << 5,
_32BITS = 1 << 6,

R = 1 << 1,
RG = 1 << 2,
RGB = 1 << 3,
RGBA = 1 << 4,

FLOAT_FORMAT = 1 << 7,

R8U = R | _8BITS,
RG8U = RG | _8BITS,
RGB8U = RGB | _8BITS,
RGBA8U = RGBA | _8BITS,

R16U = R | _16BITS,
RG16U = RG | _16BITS,
RGB16U = RGB | _16BITS,
RGBA16U = RGBA | _16BITS,

R16F = R | _16BITS | FLOAT_FORMAT,
RG16F = RG | _16BITS | FLOAT_FORMAT,
RGB16F = RGB | _16BITS | FLOAT_FORMAT,
RGBA16F = RGBA | _16BITS | FLOAT_FORMAT,

R32F = R | _32BITS | FLOAT_FORMAT,
RG32F = RG | _32BITS | FLOAT_FORMAT,
RGB32F = RGB | _32BITS | FLOAT_FORMAT,
RGBA32F = RGBA | _32BITS | FLOAT_FORMAT
};

public static class AImgFormatExtension
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;

using System.Runtime.Serialization;

namespace Artomatix.ImageLoader
{
public class AImgException : Exception
Expand Down Expand Up @@ -37,14 +38,23 @@ public static void checkErrorCode(IntPtr img, Int32 errorCode)
throw new AImgOpenFailedEmptyInputException(msg);
case -9:
throw new AImgInvalidEncodeArgsException(msg);
case -10:
throw new AImgWriteNotSupportedForFormat(msg);

default:
throw new AImgException("Unknown error code: " + errorCode + " " + msg);
}
}
}
}

}

internal class AImgWriteNotSupportedForFormat : Exception
{
public AImgWriteNotSupportedForFormat(string message) : base(message)
{
}
}

public class AImgUnsupportedFiletypeException : AImgException
{
public AImgUnsupportedFiletypeException(string msg) : base(msg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal class NativeFuncs
{
private static NativeFuncs initNative()
{
var dllPath = Path.GetFullPath("AIMG.dll");
var dllPath = Path.GetFullPath($"{AppDomain.CurrentDomain.BaseDirectory}/AIMG.dll");
#if DEBUG
var zipStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Artomatix.ImageLoader.embedded_files.binaries.zip");
NativeBinaryManager.NativeBinaryManager.ExtractNativeBinary(zipStream, dllPath);
Expand Down Expand Up @@ -69,7 +69,22 @@ private static NativeFuncs initNative()
[EntryPoint("AImgCleanUp")]
public AImgCleanUp_t AImgCleanUp;

public delegate Int32 AImgGetWhatFormatWillBeWrittenForData_t(Int32 fileFormat, Int32 inputFormat);
public delegate Int32 AIChangeBitDepth_t(Int32 format, Int32 newBitDepth);

[EntryPoint("AIChangeBitDepth")]
public AIChangeBitDepth_t AIChangeBitDepth;

public delegate Int32 AIGetBitDepth_t(Int32 format);

[EntryPoint("AIGetBitDepth")]
public AIGetBitDepth_t AIGetBitDepth;

public delegate bool AImgIsFormatSupported_t(Int32 fileFormat, Int32 outputFormat);

[EntryPoint("AImgIsFormatSupported")]
public AImgIsFormatSupported_t AImgIsFormatSupported;

public delegate Int32 AImgGetWhatFormatWillBeWrittenForData_t(Int32 fileFormat, Int32 inputFormat, Int32 outputFormat);

[EntryPoint("AImgGetWhatFormatWillBeWrittenForData")]
public AImgGetWhatFormatWillBeWrittenForData_t AImgGetWhatFormatWillBeWrittenForData;
Expand All @@ -87,7 +102,8 @@ out Int32 detectedFileFormat
public AImgOpen_t AImgOpen;

public delegate Int32 AImgWriteImage_t(
IntPtr img, IntPtr data, Int32 width, Int32 height, Int32 inputFormat, string profileName, IntPtr colourProfile, Int32 colourProfileLength,
IntPtr img, IntPtr data, Int32 width, Int32 height, Int32 inputFormat, Int32 outputFormat,
string profileName, IntPtr colourProfile, Int32 colourProfileLength,
[MarshalAs(UnmanagedType.FunctionPtr)] ImgLoader.WriteCallback writeCallback,
[MarshalAs(UnmanagedType.FunctionPtr)] ImgLoader.TellCallback tellCallback,
[MarshalAs(UnmanagedType.FunctionPtr)] ImgLoader.SeekCallback seekCallback,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("wheybags")]
[assembly: AssemblyCopyright("Artomatix Limited")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6'">
<ItemGroup>
<Reference Include="ZipStorer">
<HintPath>..\..\..\..\packages\ZipStorer\lib\net20\ZipStorer.dll</HintPath>
<HintPath>..\..\..\..\packages\ZipStorer\lib\net452\ZipStorer.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
Expand Down
Loading

0 comments on commit 916a6d2

Please sign in to comment.