build static method

List<int> build(
  1. Image image, {
  2. required LabelLanguage language,
  3. PrinterDpi dpi = PrinterDpi.dpi203,
  4. LabelCompression compression = LabelCompression.none,
  5. double? widthMm,
  6. double? heightMm,
  7. double gapMm = 2,
  8. LabelMedia media = LabelMedia.gap,
  9. int copies = 1,
  10. int threshold = 127,
  11. double topOffsetMm = 0,
})

Implementation

static List<int> build(
  Image image, {
  required LabelLanguage language,
  PrinterDpi dpi = PrinterDpi.dpi203,
  LabelCompression compression = LabelCompression.none,
  double? widthMm,
  double? heightMm,
  double gapMm = 2,
  LabelMedia media = LabelMedia.gap,
  int copies = 1,
  int threshold = 127,
  double topOffsetMm = 0,
}) {
  final bitmap = MonoBitmap.fromImage(image, threshold: threshold);
  final wMm = widthMm ?? image.width / dpi.dotsPerMm;
  final hMm = heightMm ?? image.height / dpi.dotsPerMm;
  final compress = compression == LabelCompression.compressed;
  switch (language) {
    case LabelLanguage.tspl:
      return _tspl(bitmap, wMm, hMm, gapMm, media, copies, compress);
    case LabelLanguage.escPos:
      return _escPos(
        bitmap,
        media,
        copies,
        compress,
        dpi.mmToDots(topOffsetMm),
      );
    case LabelLanguage.detong:
      return _detong(bitmap, media, copies, dpi.mmToDots(topOffsetMm));
    case LabelLanguage.cpcl:
      return _cpcl(bitmap, dpi, media, copies, compress);
  }
}