Dim bitmapFilePath As String = imagepath here...
Dim bitmapFileData As Byte() = System.IO.File.ReadAllBytes(bitmapFilePath)
Dim fileSize As Integer = bitmapFileData.Length
Dim bitmapDataOffset As Integer = 0
Dim width As Integer = 50 '255
Dim height As Integer = 50 '255
Dim bitsPerPixel As Integer = 1
Dim bitmapDataLength As Integer = 400
Dim widthInBytes As Double = Math.Ceiling(width / 8.0)
Dim bitmap(bitmapDataLength) As Byte
Buffer.BlockCopy(bitmapFileData, bitmapDataOffset, bitmap, 0, bitmapDataLength)
For i As Integer = 0 To bitmapDataLength Step 1
bitmap(i) = bitmap(i) Xor &HFF
Next
Dim ZPLImageDataString As String = BitConverter.ToString(bitmap)
ZPLImageDataString = Replace(ZPLImageDataString, "-", String.Empty)
Dim zplCommand(3) As String
zplCommand(0) = "^XA"
zplCommand(1) = "^FO20,20"
zplCommand(2) =
"^GFA, " +
bitmapDataLength.ToString() + "," +
bitmapDataLength.ToString() + "," +
widthInBytes.ToString() + "," +
ZPLImageDataString
zplCommand(3) = "^XZ"
它打印出一个无意义的正方形,看起来像有人在Photoshop中应用了噪声过滤器。我在Zebra网站上找到了这个解决方案,但该图像是255/255,我需要这个50/50的图像,但我不知道我应该改变偏移量或bitmapDatalength…
您的位图颜色深度是1位吗?你不能像这样发送彩色图像,它们需要转换为b/w每像素1位。您还需要确保bitmapDataLength
变量是正确的。这应该是要发送到打印机的图像的字节数。请参见ZPL手册中的^GF
命令。如果您想在打印机上保存图像
如果你只需要转换一对图像并保存它们,你可以使用ZebraNet Bridge中的图形转换向导。它会照顾你的颜色转换,和ZPL ^GF数学,你也可以选择将图像存储在你的打印机上。
我遇到了同样的问题,并像这样解决了。从技术上讲,我不知道怎么做,但尝试一下…
Dim bitmapDataLength As Integer = 338
Dim bitmapDataOffset As Integer = 62
第一行表示图像大小(文件大小),单位为字节- 62第二行表示图像的标题大小(62)
希望能有所帮助