ESC POS command prints a picture

Source: Internet
Author: User

Print the picture as follows:

Std::vector<qbytearray> Guilauncher::convertimagetobytearray (const qimage &img) {std::vector<
  Qbytearray> cmd_serial;
  Just print image!!
  int w = img.width ();
  int rw = W/8;
  int RH = Img.height ();
  int h = ((RH + 23)/24) * 24;

  int32_t img_seg_height = h;
  Cmd_serial.push_back (Poscmd ({27, 64}));
  RECV Data!!
  Qbytearray cmd;
  int32_t img_seg_count = h/img_seg_height;
    for (int si = 0; si < Img_seg_count; si++) {cmd.clear ();
    Cmd.append (29);
    Cmd.append (118);
    Cmd.append (48);
    Cmd.append ((char) 0);
    Cmd.append ((char) (rw% 256));
    Cmd.append ((char) (rw/256));
    Cmd.append ((char) (img_seg_height% 256));

    Cmd.append ((char) (img_seg_height/256));

        for (int ph = 0, ph < img_seg_height; ph++) {for (int rwi = 0; rwi < RW; rwi++) {char t = 0x00;
          for (int j = 0; J < 8; ++j) {int image_x = RWI * 8 + J;
          int image_y = ph + si * img_seg_height;
int V;          if (image_y >= RH) {v = 0;
          } else {v = qblue (Img.pixel (image_x, image_y)) < 0xc0? 1:0;
        } t |= (v << (7-j));
      } cmd.append (t);
  }} cmd_serial.push_back (cmd);
  } cmd_serial.push_back (Poscmd ({29, 86, 66, 0}));
return cmd_serial; }
Where cmd_serial is the POS command sequence, which is sent sequentially to the POS machine.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.