Awesome
<img src="doc/jpeg_ls_logo.png" alt="JPEG-LS Logo" width="100"/>CharLS.Native .NET
CharLS.Native .NET is an adapter assembly that provides access to the native CharLS JPEG-LS C++ implementation for .NET based applications.
JPEG-LS (ISO-14495-1) is a lossless/near-lossless compression standard for continuous-tone images.
Features
- .NET Framework 4.8, .NET 6.0, Net 7.0 and .NET 8.0 class library.
- Support for the .NET platforms: Windows, Linux and macOS.
- Includes prebuilt native CharLS Windows DLLs (x86, x64 and ARM64).
How to use
CharLS.Native can be added to your C# project using the dotnet command line or the NuGet Package Manager in Visual Studio.
Install using the dotnet command line
dotnet add package CharLS.Native
Windows specific installation steps
The NuGet package comes with prebuilt CharLS DLLs for the x86, x64 and ARM64 targets. The Microsoft Visual C++ 2015-2022 Redistributable (v14.38 or newer) needs to be installed on the target system.
Linux specific installation steps
A prebuild CharLS shared library can be installed using the Apt package manager:
sudo apt install libcharls2
MacOS specific installation steps
A prebuild CharLS shared library can be installed using the Homebrew package manager:
brew install team-charls/tap/charls
How to use the C# classes in the NuGet package
A sample application is included in the GitHub repository that demonstrates how to convert common image types like .bmp, .png and .jpg to .jls (JPEG-LS).
General steps to build this repository
- Use Git to get a clone of this repository:
git clone --recurse-submodules
- Use CMake to build the native C++ shared library, see the CharLS project how to do that. When building with Visual Studio, this step can be skipped.
- Use the .NET 8.0 CLI or Visual Studio 2022 (v17.8 or newer) to build the solution file CharLSNativeDotNet.sln. For example:
dotnet build && dotnet test && dotnet publish
to build the nuget package.
Building Windows DLLs and code signing all components
Building the NuGet package with signed Windows DLLs can only be done on the Window platform with Visual Studio 2022 or with Build tools for Visual Studio 2022.
To support code signing with a code signing certificate, stored on a smart card, a Windows command file is available: create-signed-nuget-package.cmd
.
Instructions:
- Open a Visual Studio Developer Command Prompt
- Go the root of the cloned repository
- Ensure the code signing certificate is available
- Execute the command
create-signed-nuget-package.cmd certificate-thumb-print time-stamp-url
The certificate thumbprint and time stamp URL arguments are depending on the used code signing certificate.
All DLLs and the NuGet package itself will be signed.
About the JPEG-LS image compression standard
More information about JPEG-LS can be found in the README from the C++ CharLS project. This repository also contains instructions how the build the native C++ CharLS shared library from source.