when i add DBRequestManager.bas to my b4j project, i got error message "Unknown type: bitmap"
"Are you missing a library reference?"
B4X:
Public Sub ImageToBytes(Image As Bitmap) As Byte()
Dim out As OutputStream
out.InitializeToBytesArray(0)
Image.WriteToStream(out, 100, "JPEG")
out.Close
Return out.ToBytesArray
End Sub
'Converts a bytes array to an image (for BLOB fields).
Public Sub BytesToImage(bytes() As Byte) As Bitmap
Dim In As InputStream
In.InitializeFromBytesArray(bytes, 0, bytes.Length)
Dim bmp As Bitmap
bmp.Initialize2(In)
Return bmp
End Sub
Bitmap does not exist in B4J. Here you need to use Image
Something like
B4X:
Public Sub BytesToImage(bytes() As Byte) As Image
Dim In As InputStream
In.InitializeFromBytesArray(bytes, 0, bytes.Length)
Dim bmp As Image
bmp.Initialize2(In)
Return bmp
End Sub
I think @Erel should change the bas-file fo match B4J ;-)
I think this should be ok for the other side
B4X:
'Converts an image to a bytes array (for BLOB fields).
Public Sub ImageToBytes(Img As Image) As Byte()
Dim out As OutputStream
out.InitializeToBytesArray(0)
Img.WriteToStream(out, 100, "JPEG")
out.Close
Return out.ToBytesArray
End Sub