Skip to content

mcraiha/libktxsharp

Repository files navigation

libktxsharp

Managed .NET 10/.NET 8 library for handling KTX File Format and KTX 2.0 file format.

Build status

Nuget

https://www.nuget.org/packages/LibKTX/

Why

Because KTX specs are public and I needed something like this for my canceled project

How to use

  1. Get nuget, build .dll or include lib folder in your project
  2. Use following code examples

KTX

using KtxSharp;

byte[] ktxBytes = File.ReadAllBytes("myImage.ktx");

KtxStructure ktxStructure = null;
using (MemoryStream ms = new MemoryStream(ktxBytes))
{
	ktxStructure = KtxLoader.LoadInput(ms);
}

Console.WriteLine(ktxStructure.header.pixelWidth);

KTX2 (standalone classes)

using KtxSharp;

byte[] ktx2Bytes = File.ReadAllBytes("myImage.ktx2");

Ktx2Structure ktx2Structure = null;
using (MemoryStream ms = new MemoryStream(ktx2Bytes))
{
	ktx2Structure = Ktx2Loader.LoadInput(ms);
}

Console.WriteLine(ktx2Structure.ktx2Header.pixelWidth);

KTX2 (view over existing memory)

using KtxSharp;

byte[] ktx2Bytes = File.ReadAllBytes("myImage.ktx2");

Ktx2View ktx2View = new Ktx2View(ktx2Bytes);

Console.WriteLine(ktx2View.GetPixelWidth());

How do I build this

Requirements

.NET 8 (or newer) environment

Build .dll

Move to lib folder and run

dotnet build

Build nuget

Move to lib folder and run

dotnet pack -o out --configuration Release --include-source --include-symbols

Testing

Requirements

  • nunit
  • NUnit3TestAdapter
  • Microsoft.NET.Test.Sdk

All requirements are restored when you run

dotnet restore

Run tests

Just call

dotnet test

What is in

  • Basic KTX read functionality
  • Some test cases

What is partially in

  • KTX write support

What is missing

  • More files for testing
  • Benchmarks

License

All code is released under "Do whatever you want" license aka Unlicense

About

Managed C# library for handling KTX and KTX2.0 File Formats

Topics

Resources

License

Stars

Watchers

Forks

Contributors