C# port of stb_dxt.h
There are two ways of referencing StbDxtSharp in the project:
Through nuget: https://www.nuget.org/packages/StbDxtSharp/
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.
using(varstream=TitleContainer.OpenStream("image.png")){// Load the image using StbImageSharp(https://github.com/StbSharp/StbImageSharp)varir=ImageResult.FromStream(stream,ColorComponents.RedGreenBlueAlpha);// Compress it using StbDxtSharpvarcompressedData=StbDxt.CompressDxt5(ir.Width,ir.Height,ir.Data);// Create texture from the compressed data_texture=newTexture2D(GraphicsDevice,ir.Width,ir.Height,false,SurfaceFormat.Dxt5);_texture.SetData(compressedData);}Public Domain