Skip to content

wowdev/BLPSharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BLPSharp (formerly known as SereniaBLPLib)

.NET 8.0+ library for decoding BLP textures. Uses TinyBCSharp for fast texture decompression.

Initially created under the name of SereniaBLPLib by Xalcon & later maintained by hazzik & tomrus88.

Available on NuGet.

Notes

Due to not relying on any specific image library anymore, support for BLPs containing JPEG-encoded data was removed and will throw a NYI exception. If someone wants to add this back without relying on a specific image library, feel free to open a PR.

Sample usage

    using (var fs = File.OpenRead("test.blp"))
    {
        var blp = new BLPFile(fs);
        var pixels = blp.GetPixels(mipmapLevel, out int w, out int h);
        // Pixel handling code, see below!
    }

System.Drawing.Bitmap

    Bitmap bmp = new Bitmap(w, h);
    BitmapData bmpdata = bmp.LockBits(new System.Drawing.Rectangle(0, 0, w, h), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
    Marshal.Copy(pixels, 0, bmpdata.Scan0, pixels.Length);
    bmp.UnlockBits(bmpdata);

ImageSharp

    var image = SixLabors.ImageSharp.Image.LoadPixelData<Bgra32>(pixels, w, h);

SkiaSharp

    var bitmap = new SKBitmap(w, h, SKColorType.Bgra8888, SKAlphaType.Unpremul);
    using var pixmap = bitmap.PeekPixels();
    var data = pixmap.GetPixelSpan<byte>();
    pixels.CopyTo(data);

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages