我有一台 Epson-TMH6000III 热敏打印机,我想使用 ESC/POS 命令打印一些位图。
但在此之前,我想用 ESC/POS 打印图像命令打印一个非常简单的单行。
这是我的尝试:
namespace printingImageMode
{
class Program
{
static void Main(string[] args)
{
Bitmap bmp = new Bitmap(@"C:\Users\falamarzi\Desktop\Kyan Graphic Viewer\jTest.jpg");
int msb = (int)(bmp.Width & 0x0000ff00) >> 8;
int lsb = (int)(bmp.Width & 0x000000ff);
byte msbB = Convert.ToByte(msb);
byte lsbB = Convert.ToByte(lsb);
byte[] enter_To_Image_Printing_Mode_Command = new byte[] { (byte)AsciiControlChars.ESC, (byte)DensityCommand.EightDot_SD, msbB, lsbB };
byte[] imageData = new byte[lsb + msb * 256];
for (int i = 0; i < imageData.Length; i++)
{
imageData[i] = 0xff;
}
byte[] complete_Command = new byte[enter_To_Image_Printing_Mode_Command.Length + imageData.Length];
enter_To_Image_Printing_Mode_Command.CopyTo(complete_Command, 0);
imageData.CopyTo(complete_Command, enter_To_Image_Printing_Mode_Command.Length);
SerialPort sPort = new SerialPort("COM5");
sPort.Open();
sPort.Write(complete_Command, 0, complete_Command.Length);
}
}
public enum AsciiControlChars : byte
{
ESC = 0x1b,
}
public enum DensityCommand : byte
{
EightDot_SD = 0x00,
EightDot_DD = 0x01,
TwentyFourDot_SD = 0x20,
TwentyFourDot_DD = 0x21,
}
}
我没有得到结果。我感谢您在这方面的任何帮助。