如何将单色图像转换为热敏打印机的位格式 [英] How to convert monochrome image to bitwise format for thermal printer
本文介绍了如何将单色图像转换为热敏打印机的位格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I'm using a Custom s'print DPT100-S thermal printer to made a receipt printing application.
It is able to print graphics using 384 pixels in one line. This data has to be passed on to the printer using 48 bytes (48x8=384). So, each 'bit' represents one dot to be printed (bit will be '0' for white and '1' for black).
So, I need to create a program which will read a monochrome BMP generated in Windows Paint(or any other program) and convert it into this bit format using a C program in Linux.
Please guide me.
解决方案
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
这篇关于如何将单色图像转换为热敏打印机的位格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文