printColumnImage static method

List<int> printColumnImage(
  1. Uint8List imageData,
  2. int width,
  3. int height
)

Print image using ESC * command (column format)

Implementation

static List<int> printColumnImage(Uint8List imageData, int width, int height) {
  List<int> command = [];

  // Set line spacing to 0
  command.addAll([0x1B, 0x33, 0x00]); // ESC 3 n

  // ESC * - Select bit-image mode
  command.addAll([0x1B, 0x2A]); // ESC *
  command.add(0x21); // m = 33 (24-dot double-density)

  // Width in dots
  command.addAll([width & 0xFF, (width >> 8) & 0xFF]); // nL nH

  // Image data
  command.addAll(imageData);

  // Line feed
  command.add(0x0A);

  // Reset line spacing
  command.addAll([0x1B, 0x32]); // ESC 2

  return command;
}