zplCore.comzplCore.com

ZplGraphicDecoder

public static class ZplGraphicDecoder

Decodes ZPL graphic data (^GF, ~DG, ~DY) into a 1-bit-per-pixel byte array (MSB first, 1 = black). Supports ASCII hex incl. Zebra run-length compression, :Z64: (zlib+base64), :B64: and raw binary.

Methods

Method SignatureReturnsDescription
static # Decode(string data, int bytesPerRow, int totalBytes)byte[]Decodes graphic data without a size limit (trusted input only).
static # Decode(string data, int bytesPerRow, int totalBytes, int maxBytes)byte[]Decodes graphic data. Never throws for malformed data (invalid base64/zlib yields an empty/zero-padded result). data: Field data: hex (optionally ZPL-compressed), :Z64: or :B64:. · bytesPerRow: Bytes per graphic row. · totalBytes: Total number of graphic bytes. · maxBytes: Upper bound for the decoded size (incl. totalBytes and zlib output); exceeding it throws InvalidDataException. 0 = unlimited.
static # DecodeAsciiHex(string data, int bytesPerRow, int totalBytes)byte[]ASCII hex with ZPL compression: G..Y = repeat 1..19, g..z = repeat 20..400 (step 20), ',' = rest of row 0, '!' = rest of row 1, ':' = repeat previous row. Counts apply to the following hex nibble.
static # DecodeAsciiHex(string data, int bytesPerRow, int totalBytes, int maxBytes)byte[]
static # DecodeBinary(string data, int totalBytes)byte[]Binary (format B) data as it appears in the ZPL string (Latin-1 chars → bytes).
static # DecodeBinary(string data, int totalBytes, int maxBytes)byte[]
static # EncodeAsciiHex(byte[] data)stringEncodes a 1bpp buffer as uncompressed ASCII hex (for ^GFA output).
static # EncodeZ64(byte[] data)stringEncodes a 1bpp buffer as :Z64: with CRC16 (CCITT, as used by Zebra).