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 ...