Skip to content

StbSharp/StbDxtSharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StbDxtSharp

NuGet Build status Chat

C# port of stb_dxt.h

Adding Reference

There are two ways of referencing StbDxtSharp in the project:

  1. Through nuget: https://www.nuget.org/packages/StbDxtSharp/

  2. As source code. There are two options:

    a. Add src/StbDxtSharp.csproj to the solution

    b. Include *.cs from folder "src" directly in the project. In this case, it might make sense to add STBSHARP_INTERNAL build compilation symbol to the project, so StbDxtSharp classes would become internal.

FNA/MonoGame Sample Code

using (var stream = TitleContainer.OpenStream("image.png"))
{
    // Load the image using StbImageSharp(https://github.com/StbSharp/StbImageSharp)
    var ir = ImageResult.FromStream(stream, ColorComponents.RedGreenBlueAlpha);

    // Compress it using StbDxtSharp
    var compressedData = StbDxt.CompressDxt5(ir.Width, ir.Height, ir.Data);

    // Create texture from the compressed data
    _texture = new Texture2D(GraphicsDevice, ir.Width, ir.Height, false, SurfaceFormat.Dxt5);
    _texture.SetData(compressedData);
}

License

Public Domain

Releases

No releases published

Packages

No packages published