本文介绍了如何将单色图像转换为按位格式的热敏打印机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用热敏打印机进行收据打印应用程序。
I'm using a Custom s'print DPT100-S thermal printer to made a receipt printing application.
可以在一行中使用384个像素打印图形。该数据必须使用48字节(48×8 = 384)传递到打印机。所以,每个位表示一个要打印的点(位为白色为0,黑色为1)。
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).
所以,我需要创建一个程序将读取Windows Paint(或任何其他程序)中生成的单色BMP,并使用Linux中的C程序将其转换为该位格式。
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.
请指导我
推荐答案
伪代码:
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
这篇关于如何将单色图像转换为按位格式的热敏打印机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!