printRasterImage static method

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

Print raster image using GS v 0 command

Implementation

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

  // GS v 0 - Print raster bit image
  command.addAll([0x1D, 0x76, 0x30, 0x00]); // GS v 0 m

  // Add width (in bytes)
  int widthBytes = (width + 7) ~/ 8;
  command.addAll([widthBytes & 0xFF, (widthBytes >> 8) & 0xFF]); // xL xH

  // Add height
  command.addAll([height & 0xFF, (height >> 8) & 0xFF]); // yL yH

  // Add image data
  command.addAll(imageData);

  return command;
}