Skip to content

BmpEncoder ​

Namespace: Hex1b.Automation

Assembly: Hex1b.dll

Encodes raw pixel data to BMP format for embedding in SVG as data URIs.

csharp
public static class BmpEncoder

Inheritance ​

Object → BmpEncoder

Methods ​

EncodeToBmp(int, int, byte[]) ​

Encodes RGBA pixel data to raw BMP bytes.

Parameters:

  • width (Int32): Image width in pixels.
  • height (Int32): Image height in pixels.
  • rgbaPixels (Byte[]): RGBA pixel data (4 bytes per pixel).

Returns: Byte[]

Complete BMP file as byte array.

csharp
public static byte[] EncodeToBmp(int width, int height, byte[] rgbaPixels)

ToDataUri(SixelImage) ​

Encodes RGBA pixel data to a base64 BMP data URI.

Parameters:

Returns: String

A data URI containing the BMP image.

csharp
public static string ToDataUri(SixelImage image)

Remarks ​

BMP is used because it's universally supported by browsers and requires no compression libraries to generate. The format is simple: a fixed header followed by raw pixel data.

This encoder produces 24-bit RGB BMP files (no alpha channel in output, but transparent pixels are rendered as a background color).

Released under the MIT License.