War3Net.Drawing.Blp 6.0.2

dotnet add package War3Net.Drawing.Blp --version 6.0.2
                    
NuGet\Install-Package War3Net.Drawing.Blp -Version 6.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="War3Net.Drawing.Blp" Version="6.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="War3Net.Drawing.Blp" Version="6.0.2" />
                    
Directory.Packages.props
<PackageReference Include="War3Net.Drawing.Blp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add War3Net.Drawing.Blp --version 6.0.2
                    
#r "nuget: War3Net.Drawing.Blp, 6.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package War3Net.Drawing.Blp@6.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=War3Net.Drawing.Blp&version=6.0.2
                    
Install as a Cake Addin
#tool nuget:?package=War3Net.Drawing.Blp&version=6.0.2
                    
Install as a Cake Tool

War3Net.Drawing.Blp

About

War3Net.Drawing.Blp is a .NET library for reading and writing BLP texture files, an image format used by Blizzard games including Warcraft III and World of Warcraft. It is part of the War3Net modding library.

Key features

  • Read BLP1 files (Warcraft III: Reign of Chaos and The Frozen Throne)
  • Read BLP2 files (World of Warcraft)
  • Encode images to BLP1 format with JPEG compression
  • Support for multiple compression types (JPEG, palettized, DXT1/DXT3/DXT5)
  • Extract pixel data in BGRA or RGBA format
  • Access all mipmap levels within a BLP file
  • Automatic mipmap generation when encoding
  • Windows-specific BitmapSource conversion (WPF)

How to Use

Read a BLP file and extract pixel data

using War3Net.Drawing.Blp;

// Open and read the BLP file
using var stream = File.OpenRead("texture.blp");
using var blpFile = new BlpFile(stream);

// Get image dimensions
int width = blpFile.Width;
int height = blpFile.Height;

// Extract pixel data (BGRA format by default)
byte[] pixels = blpFile.GetPixels(mipMapLevel: 0, out int w, out int h);

Extract pixel data in RGBA format

using War3Net.Drawing.Blp;

using var stream = File.OpenRead("texture.blp");
using var blpFile = new BlpFile(stream);

// Get pixels in RGBA order instead of BGRA
byte[] rgbaPixels = blpFile.GetPixels(mipMapLevel: 0, out int w, out int h, bgra: false);

Access mipmap levels

using War3Net.Drawing.Blp;

using var stream = File.OpenRead("texture.blp");
using var blpFile = new BlpFile(stream);

// Get the number of available mipmaps
int mipMapCount = blpFile.MipMapCount;

// Extract a specific mipmap level (0 = largest, higher = smaller)
for (int level = 0; level < mipMapCount; level++)
{
    byte[] mipMapPixels = blpFile.GetPixels(level, out int mipWidth, out int mipHeight);
    // Process mipmap...
}

Encode an image to BLP1 format

using War3Net.Drawing.Blp;

// Prepare BGRA pixel data (4 bytes per pixel)
int width = 256;
int height = 256;
byte[] bgraPixels = new byte[width * height * 4];
// ... populate pixel data ...

// Configure encoding options
var options = new Blp1EncodingOptions
{
    GenerateMipmaps = true,
    JpegQuality = 85,
};

// Encode to BLP1
var encoder = new BlpEncoder(options);
using var outputStream = File.Create("output.blp");
encoder.Encode(outputStream, width, height, bgraPixels);

Convert to BitmapSource (Windows WPF)

using War3Net.Drawing.Blp;
using System.Windows.Media.Imaging;

using var stream = File.OpenRead("texture.blp");
using var blpFile = new BlpFile(stream);

// Get a WPF BitmapSource (Windows only)
BitmapSource bitmap = blpFile.GetBitmapSource(mipMapLevel: 0);

Main Types

The main types provided by this library are:

  • War3Net.Drawing.Blp.BlpFile - Reads and decodes BLP image files
  • War3Net.Drawing.Blp.BlpEncoder - Encodes images to BLP1 format with JPEG compression
  • War3Net.Drawing.Blp.Blp1EncodingOptions - Configuration options for BLP1 encoding
  • War3Net.Drawing.Blp.FileFormatVersion - BLP format version identifiers (BLP0, BLP1, BLP2)

Feedback and contributing

War3Net.Drawing.Blp is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.

Disclaimer

This README was generated with the assistance of AI and may contain inaccuracies. Please verify the information and consult the source code for authoritative details.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net6.0-windows7.0 is compatible.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
6.0.2 90 3/1/2026
6.0.1 116 2/1/2026
6.0.0 111 1/25/2026
5.9.0 263 10/30/2025
5.8.0 197 9/6/2025
5.6.1 1,101 1/7/2023
5.6.0 459 12/20/2022
5.5.5 546 11/13/2022
5.5.3 566 10/29/2022
5.5.2 562 10/25/2022
5.5.0 699 8/20/2022
5.4.5 659 5/27/2022
5.4.1 631 4/8/2022
5.4.0 644 2/13/2022
5.0.0 695 12/14/2020
2.0.1 615 10/27/2020
2.0.0 685 9/14/2020
1.1.0 818 7/9/2019
1.0.0 751 7/8/2019