B4J Question DBRequestManager.bas got a error

dragonguy

Active Member
Licensed User
Longtime User
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

my b4j version is 4.20.
please help me.
 

DonManfred

Expert
Licensed User
Longtime User
Public Sub BytesToImage(bytes() As Byte) As Bitmap
You found this snippet in b4a forum, right?

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
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
i took from here
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
 
Upvote 0

dragonguy

Active Member
Licensed User
Longtime User
i change the code still facing same problem,
"Unknown type: Image"
"Are you missing a library reference?"
 
Upvote 0
Top