在VB6中使用GW命令打印到Zebra打印机

时间:2016-02-15 10:51:58

标签: printing vb6 bmp epl zebra

我正在尝试使用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

Here是Zebra网站上的支持文章供参考

打印机正在接受我的命令并正确连接。我没有打印条形码等问题。打印机是TLP2742,但我认为所有使用EPL的打印机都采用相同的方法。

修改:And the EPL Programmers manual

编辑2:添加了大部分正常工作的代码,here是一个与上述代码问题相同的问题

0 个答案:

没有答案