C # Heat-sensitive print picture serial port print picture

Source: Internet
Author: User

As shown in the picture, slowly and step out of the

       Serial Communication class
Public System.IO.Ports.SerialPort SerialPort = null;
SerialPort = new System.IO.Ports.SerialPort ("COM1");
Serialport.baudrate =19200;
Serialport.databits = 8;
Serialport.stopbits = System.IO.Ports.StopBits.One;
serialport.parity = System.IO.Ports.Parity.None;
Serialport.open ();
        ///<summary>///print bitmap logo///</summary> <param name= "bitmap" ></param> public void PrintBitmap2 (bitmap bitmap) {i NT Width=bitmap.
            Width-1; int Height = (int) (bitmap.
            Height)/8;
            int spacenum= (int) (244-width)/2;
            int x0,x1, x2=0,x3=0,x4=0,x5=0,x6=0,x7=0;
            byte[] PBuf = new byte[1024*1024];
            int point = 0;
            pbuf[point++] = 27;
            pbuf[point++] = (byte) ' 3 ';
            pbuf[point++] = 16;
            pbuf[point++] = 27;
            pbuf[point++] = (byte) ' R ';
            pbuf[point++] = 0; Func<color, bool> isnearwhite = color => {if color. A + color. B + color. G + color.
                R >= 255 + + + +) {return false;
            return true;
            }; for (int n = 0; n < HeigHt
               n++) {pbuf[point++] = 27;
               pbuf[point++] = (byte) ' * ';
               pbuf[point++] = 0;
               pbuf[point++] = (byte) (width+spacenum);
               pbuf[point++] = 0;
               for (int i = 0; i< spacenum; i++) {pbuf[point++] = 0;
                  for (int i = 0; i < Width; i++) {x0=0;
                  x1=0;
                  x2=0;
                  x3=0;
                  x4=0;
                  x5=0;
                  x6=0;
                  
                  x7=0; if (Isnearwhite (bitmap).
                  GetPixel (i,0+ (n*8))) x0 = 128; if (Isnearwhite (bitmap).
                  GetPixel (I, 1 + (n * 8))) x1 = 64; if (Isnearwhite (bitmap).
                  GetPixel (I, 2 + (n * 8))) x2 = 32; if (Isnearwhite (bitmap). GetPixel (I, 3 + (n * 8))) x3 = 16; if (Isnearwhite (bitmap).
                  GetPixel (I, 4 + (n * 8))) x4 = 8; if (Isnearwhite (bitmap).
                  GetPixel (I, 5 + (n * 8))) x5 = 4; if (Isnearwhite (bitmap).
                  GetPixel (I, 6 + (n * 8))) x6 = 2; if (Isnearwhite (bitmap).
                  GetPixel (I, 7 + (n * 8))) X7 = 1;
               Pbuf[point++]= (Byte) (x0 ^ x1 ^ x2 ^ x3 ^ x4 ^ x5 ^ x6 ^x7);
               } pbuf[point++] = 13;
            pbuf[point++] = 10;
       } serialport.write (PBuf, 0, point); }

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.