![]() |
VOOZH | about |
dotnet add package BCnEncoder.Net --version 2.3.0
NuGet\Install-Package BCnEncoder.Net -Version 2.3.0
<PackageReference Include="BCnEncoder.Net" Version="2.3.0" />
<PackageVersion Include="BCnEncoder.Net" Version="2.3.0" />Directory.Packages.props
<PackageReference Include="BCnEncoder.Net" />Project file
paket add BCnEncoder.Net --version 2.3.0
#r "nuget: BCnEncoder.Net, 2.3.0"
#:package BCnEncoder.Net@2.3.0
#addin nuget:?package=BCnEncoder.Net&version=2.3.0Install as a Cake Addin
#tool nuget:?package=BCnEncoder.Net&version=2.3.0Install as a Cake Tool
A Cross-platform BCn / DXT encoding libary for .NET
BCnEncoder.NET is a library for compressing rgba images to different block-compressed formats. It has no native dependencies and is .NET Standard 2.1 & 2.0 compatible.
Supported formats are:
The current state of this library is in development but quite usable. I'm planning on implementing support for more codecs and different algorithms. The current version is capable of encoding and decoding BC1-BC7 images in both KTX or DDS formats.
.NET Standard 2.0 support is experimental, and relies on PolySharp & Microsoft.Bcl.Numerics.
Please note, that the API might change between versions.
Current dependencies are:
Additionally, for .NET Standard 2.0:
This library has extension packages available for the following image libraries:
The extension packages provide extension methods for ease of use with the image library.
If you're upgrading from 1.X.X to version 2, expect some of your exsting code to be broken. ImageSharp was removed as a core dependency in version 2.0, so the code will no longer work with ImageSharp's Image types by default. You can install the extension package for ImageSharp to continue using this library easily with ImageSharp apis.
The below examples are using the ImageSharp extension package. For more detailed usage examples, you can go look at the unit tests.
Remember add the following usings to the top of the file:
using BCnEncoder.Encoder;
using BCnEncoder.Decoder;
using BCnEncoder.Shared;
using BCnEncoder.ImageSharp;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
Here's an example on how to encode a png image to BC1 without alpha, and save it to a file.
using Image<Rgba32> image = Image.Load<Rgba32>("example.png");
BcEncoder encoder = new BcEncoder();
encoder.OutputOptions.GenerateMipMaps = true;
encoder.OutputOptions.Quality = CompressionQuality.Balanced;
encoder.OutputOptions.Format = CompressionFormat.Bc1;
encoder.OutputOptions.FileFormat = OutputFileFormat.Ktx; //Change to Dds for a dds file.
using FileStream fs = File.OpenWrite("example.ktx");
encoder.EncodeToStream(image, fs);
And how to decode a compressed image from a KTX file and save it to png format.
using FileStream fs = File.OpenRead("compressed_bc1.ktx");
BcDecoder decoder = new BcDecoder();
using Image<Rgba32> image = decoder.DecodeToImageRgba32(fs);
using FileStream outFs = File.OpenWrite("decoding_test_bc1.png");
image.SaveAsPng(outFs);
How to encode an HDR image with BC6H. (HdrImage class reads and writes Radiance HDR files. This class is experimental and subject to be removed)
HdrImage image = HdrImage.Read("example.hdr");
BcEncoder encoder = new BcEncoder();
encoder.OutputOptions.GenerateMipMaps = true;
encoder.OutputOptions.Quality = CompressionQuality.Balanced;
encoder.OutputOptions.Format = CompressionFormat.Bc6U;
encoder.OutputOptions.FileFormat = OutputFileFormat.Ktx; //Change to Dds for a dds file.
using FileStream fs = File.OpenWrite("example.ktx");
encoder.EncodeToStreamHdr(image.PixelMemory, fs);
How to decode a BC6H encoded file.
using FileStream fs = File.OpenRead("compressed_bc6.ktx");
BcDecoder decoder = new BcDecoder();
Memory2D<ColorRgbFloat> pixels = decoder.DecodeHdr2D(fs);
HdrImage image = new HdrImage(pixels.Span);
using FileStream outFs = File.OpenWrite("decoded.hdr");
image.Write(outFs);
All contributions are welcome. I'll try to respond to bug reports and feature requests as fast as possible, but you can also fix things yourself and submit a pull request. Please note, that by submitting a pull request you accept that your code will be dual licensed under MIT and public domain Unlicense.
This library is dual-licensed under the Unlicense and MIT licenses.
You may use this code under the terms of either license.
Please note, that any dependencies of this project are licensed under their own respective licenses.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 is compatible. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on BCnEncoder.Net:
| Package | Downloads |
|---|---|
|
MonoGame.Framework.Content.Pipeline
The Monogame Content Pipeline for Windows, Mac and Linux is used to compile raw content to xnb files. |
|
|
Lumina
Lumina is a small, performant and simple library for interacting with FINAL FANTASY XIV game data. |
|
|
BCnEncoder.Net.ImageSharp
Adds ImageSharp apis to BCnEncoder.Net |
|
|
RenderWareBuilders
Renderware IO builder library |
|
|
FF16Tools.Files
Library for handling various FF16 file formats. |
Showing the top 20 popular GitHub repositories that depend on BCnEncoder.Net:
| Repository | Stars |
|---|---|
|
MonoGame/MonoGame
One framework for creating powerful cross-platform games.
|
|
|
Norbyte/lslib
Tools for manipulating Divinity Original Sin and Baldur's Gate 3 files
|
|
|
bcssov/IronyModManager
Mod Manager for Paradox Games. Official Discord: https://discord.gg/t9JmY8KFrV
|
|
|
amerkoleci/alimer
Cross-platform .NET 10 C# game engine.
|
|
|
FanTranslatorsInternational/Kuriimu2
Kuriimu is a general purpose game translation project manager and toolkit for authors of fan translations and game mods.
|
|
|
xivapi/SaintCoinach
A .NET library written in C# for extracting game assets and reading game assets from Final Fantasy XIV: A Realm Reborn.
|
|
|
Markemp/Cryengine-Converter
A c# program to convert Crytek files to Collada (XML) format
|
|
|
MeltyPlayer/MeltyTool
Multitool for viewing/extracting assets from various N64/GCN/3DS/PC games en-masse.
|
|
|
Nenkai/PDTools
A collection of utilities for working around certain Gran Turismo games.
|
|
|
Amethyst-szs/MoonFlow
Modding application for Super Mario Odyssey, specializing in text editing and event flowcharts
|
|
|
ME3Tweaks/LegendaryExplorer
Editor toolset for Mass Effect Trilogy and Mass Effect Legendary Edition
|
|
|
Nenkai/GBFRDataTools
Tools/Libraries for dealing with Granblue Fantasy: Relink.
|
|
|
NotAdam/Lumina
A simple, performant and extensible framework for interacting with FFXIV game data
|
|
|
X-Hax/sa_tools
Sonic Adventure Toolset
|
|
|
R2NorthstarTools/VTOL
A Manager and Installer For the Titanfall 2 +Northstar launcher.
|
|
|
nanami5270/GARbro-Mod
Fork of morkt/GARbro
|
|
|
EmK530/BloxDump
A program that dumps game assets cached by Roblox.
|
|
| bernatvadell/muonline | |
|
LittleBigRefresh/Refresh
A second-generation custom server for LittleBigPlanet that focuses on quality of life features and improving user experience.
|
|
|
MapStudioProject/Track-Studio
A powerful MK8 map editor for creating and editing track models, objects, paths and animations.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 2.3.0 | 5,671 | 3/5/2026 |
| 2.2.1 | 59,063 | 5/4/2025 |
| 2.2.0 | 6,071 | 3/7/2025 |
| 2.1.0 | 117,206 | 9/18/2021 |
| 2.0.3 | 17,580 | 3/22/2021 |
| 2.0.2 | 970 | 2/18/2021 |
| 2.0.1 | 1,785 | 2/16/2021 |
| 2.0.0 | 787 | 2/12/2021 |
| 1.2.3 | 1,523 | 10/20/2020 |
| 1.2.2 | 932 | 5/24/2020 |
| 1.2.1 | 815 | 4/30/2020 |
| 1.2.0 | 874 | 4/30/2020 |
| 1.1.1 | 776 | 4/28/2020 |
| 1.1.0 | 837 | 4/22/2020 |
| 1.0.1 | 759 | 4/20/2020 |
| 1.0.0 | 837 | 4/20/2020 |
2.3.0
- Add .NET Standard 2.0 support
- Fix some DecodeAllMipMaps methods not decoding all MipMaps