B4J Question BMP Image To Byte Array

nazilabdulla

Member
Licensed User
Longtime User
How to read / write bytes from/to B4XBitmap ?
Image can be processed by this method ?
Is it best solution for image recognition ? Any other better way ?
 
Last edited:

xulihang

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


BytesToImage:
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)
    In.Close
    Return bmp
End Sub
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
@xulihang: Why are you taking credit for these tools when they were made by Erel in this link in 2018. How are they different. Maybe you mean 'Used them with B4J'?
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
@Mahares I think you are reading their footer, the tools they made are below.
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
Is it best solution for image recognition ? Any other better way ?
Search forum
 
Last edited:
Upvote 0
Top