Sub print(newBm As Bitmap)
OS=Serial1.OutputStream
Dim xL As Byte = ((newBm.Width + 7) / 8 mod 256)
Dim xH As Byte = ((newBm.Width + 7) / 8 / 256)
Dim line As Byte = 10
Dim bmpRow As Int = (newBm.Height + line - 1) / line
Dim width As Int = (newBm.Width + 7) / 8
Dim pixels() As Byte
Dim bcode() As Byte = Array As Byte(29, 118, 48, 0)
Dim i As Int
Log("bmp width = " & newBm.width & ", bmp height=" & newBm.Height)
Log("bmpRow =" & bmpRow)
Dim jo As JavaObject
pixels = jo.InitializeStatic("driver.BitmapConvertUtil").RunMethod("convert", Array(newBm))
Dim offSet, osLenght As Int
For i = 0 To bmpRow
Dim yL As Byte
Dim yH As Byte
Dim buf() As Byte
If i <> bmpRow - 1 Then
yL = line
yH = 0
buf = Array As Byte(bcode(0), bcode(1), bcode(2), bcode(3), xL, xH, yL, yH)
OS.WriteBytes(buf,0,buf.Length-1)
offSet = (width * i * line)
osLenght = (width * line * (i + 1) - 1)
Log( "row (i) = " & i & ", width = " & width & ", line =" & line)
Log( "Offset = " & offSet & ", Lenght = " & osLenght)
OS.WriteBytes(pixels, offSet, osLenght)
buf = Array As Byte(10)
OS.WriteBytes(buf,0,buf.Length-1)
Else
yL = (newBm.Width mod line)
yH = 0
buf = Array As Byte(bcode(0), bcode(1), bcode(2), bcode(3), xL, xH, yL, yH)
OS.WriteBytes(buf,0,buf.Length-1)
offSet = (width * i * line)
osLenght = pixels.length - 1
OS.WriteBytes(pixels, offSet, osLenght)
buf = Array As Byte(10)
OS.WriteBytes(buf,0,buf.Length-1)
End If
Next
Return
End Sub