How to convert monochrome image to bitwise format for thermal printer

我怕爱的太早我们不能终老 提交于 2019-12-04 11:42:54

Pseudo code:

Read BMP
For each row in BMP
    For each group of 8 pixels in row
        output_byte = 0
        For each pixel in current group of 8
            output_byte <<= 1             // shift output_byte left by one bit
            output_byte |= (pixel != 0)   // set rightmost bit in output_byte
                                          // according to input pixel value
        Save output_byte in bitmap

Take a look at halftoning.

A quick Google will get you references and Java applet like here: http://www.markschulze.net/halftone/index.html

If you don't have to create your own program and you are happy to use off the shelf software, try ImageMagick's convert command: http://www.imagemagick.org/Usage/quantize/#halftone e.g.

convert myfile.jpg -colorspace Gray  -ordered-dither h4x4a printable-file.bmp
talekeDskobeDa

This link has a software called LCD assistant which does the same thing as you need. You have to use paint to convert any image to bitmap and then import that bmp image into the software. The output you can choose to be 384 X xyz. You get the output pixels in HEX.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!