Hi All
I am trying to save a barcode image to a file, so I can read it back.
The code below is returning array size = 0.
I also tried the equivalent code for Bitmap instead of B4XBitmap
Any ideas?
I am trying to save a barcode image to a file, so I can read it back.
The code below is returning array size = 0.
I also tried the equivalent code for Bitmap instead of B4XBitmap
Any ideas?
B4X:
Dim StringToDisplay as String = "112233445566"
'This call returns a bitmap as expected.
Dim bB4XBitmap As B4XBitmap = CreateCode128Barcode(StringToDisplay)
'This returns array size = 0
Dim bImgAsBytes() As Byte = ImageToBytes(bB4XBitmap)
Public Sub ImageToBytes(Image As B4XBitmap) As Byte()
Dim out As OutputStream
out.InitializeToBytesArray(0)
Image.WriteToStream(out, 100, "JPEG")
out.Close
Return out.ToBytesArray
End Sub
Public Sub BytesToImage(bytes() As Byte) As B4XBitmap
Dim In As InputStream
In.InitializeFromBytesArray(bytes, 0, bytes.Length)
#if B4A or B4i
Dim bmp As Bitmap
bmp.Initialize2(In)
#else
Dim bmp As Image
bmp.Initialize2(In)
#end if
Return bmp
End Sub