Dim imagem As Bitmap, x As Int, y As Int
imagem = LoadBitmap(File.DirAssets, "logopol.bmp")
Dim out As OutputStream
out.InitializeToBytesArray(0)
out.WriteBytes(Array As Byte(0x1D),0,1)
out.WriteBytes(Array As Byte(0x2A),0,1)
out.WriteBytes(Array As Byte(imagem.Width/8),0,1)
out.WriteBytes(Array As Byte(imagem.height),0,1)
For x = 0 To p.Length -1
If p(x) = -1 Then bits = bits & "0" Else bits = bits & "1"
If p(x) = -1 Then bitslinha = bitslinha & "0" Else bitslinha = bitslinha & "1"
If bits.Length = 8 Then
'Log(bits)
'count = count + 1
'Log(RetBytePOS(bits) & " " & count)
out.WriteBytes(Array As Byte(RetBytePOS(bits)),0,1)
bits = ""
End If
If bitslinha.Length = imagem.Width Then
Log(bitslinha)
bitslinha = ""
End If
Next
Log(BytesToString(out.ToBytesArray,0,out.ToBytesArray.Length,"utf-8"))
Astream.Write(Array As Byte(0x1D, 0x2A, 0, 0))
Astream.Write(out.ToBytesArray)
Astream.Write(Array As Byte(0x1D, Asc("/"), 3))
Sub RetBytePOS(bitStr As String) As Int
If bitStr.Length < 8 Then bitStr = bitStr & "00000000"
Return (bitStr.SubString2(0,1)*1)+(bitStr.SubString2(1,2)*2)+(bitStr.SubString2(2,3)*4)+(bitStr.SubString2(3,4)*8)+(bitStr.SubString2(4,5)*16)+(bitStr.SubString2(5,6)*32)+(bitStr.SubString2(6,7)*64)+(bitStr.SubString2(7,8)*128)
End Sub