我正在尝试使用 VB6 通过串行端口将图像打印到 Zebra 标签打印机。我尝试了各种文件格式(BMP 的不同位深度),最接近位深度为 4 的图像(实际打印的东西,虽然看起来不像我使用的图像)。
我假设需要 1 的位深度,因为打印机无论如何只能打印黑白,但是当我发送文件时我没有得到任何输出。我猜这是由于打印机需要更多数据,因此没有开始打印。我目前拥有的代码是:
Private Type BITMAPFILEHEADER
bfType As Integer
bfSize As Long
bfReserved1 As Integer
bfReserved2 As Integer
bfOffBits As Long
End Type
Private Type BITMAPINFOHEADER
biSize As Long
biWidth As Long
biHeight As Long
biPlanes As Integer
biBitCount As Integer
biCompression As Long
biSizeImage As Long
biXPelsPerMeter As Long
biYPelsPerMeter As Long
biClrUsed As Long
biClrImportant As Long
End Type
Private Type RGBQUAD
rgbBlue As Byte
rgbGreen As Byte
rgbRed As Byte
rgbReserved As Byte
End Type
Private Sub cmdImage_Click()
Dim BMPFileHeader As BITMAPFILEHEADER
Dim BMPInfoHeader As BITMAPINFOHEADER
Dim BMPRGBQuad() As RGBQUAD
Dim fFile As Integer
Dim bImage() As Byte
Dim padding As Integer
fFile = FreeFile
Open "img1.bmp" For Binary Access Read As fFile
Get fFile, , BMPFileHeader
Get fFile, , BMPInfoHeader
Select Case BMPInfoHeader.biBitCount
Case 1
ReDim BMPRGBQuad(1)
Case 4
ReDim BMPRGBQuad(15)
Case 8
ReDim BMPRGBQuad(255)
End Select
If BMPInfoHeader.biBitCount < 24 Then
Get fFile, , BMPRGBQuad()
End If
ReDim bImage(BMPInfoHeader.biSizeImage)
Get fFile, , bImage
Close fFile
padding = 32 - ((BMPInfoHeader.biWidth * BMPInfoHeader.biBitCount) Mod 32)
If padding = 32 Then padding = 0
padding = padding \ BMPInfoHeader.biBitCount
com.output = "N" & vblf
com.Output = "GW50,50," & (BMPInfoHeader.biWidth + padding) / 8 & "," & BMPInfoHeader.biWidth & ","
com.Output = bImage
Send vbLf & "P1,1"
End Sub
这是 Zebra 网站上的支持文章,供参考
打印机正在接受我的命令,并且连接正确。我打印条形码等没有问题。打印机是 TLP2742,但我认为所有使用 EPL 的打印机的方法都是相同的。
编辑:和EPL程序员手册
编辑 2:添加了大部分工作代码,这是一个与上面的代码有相同问题的问题