Android Question byte or base64string

MohammadNew

Active Member
Licensed User
Longtime User
Hello everyone, which is better way to insert image in database?

byte or base64string

If you know other ways tell us.

Thanks alot

warm regards
 

MohammadNew

Active Member
Licensed User
Longtime User
If you want to embed the images in the database then it is more efficient to use BLOBs (array of bytes). RDC supports BLOBs however the PHP script from the MySQL example doesn't.

Thanks Erel, could you see and tell me what is better ? If you have other about better way tell us please .


B4X:
Sub chooser_Result(Success As Boolean, Dir As String, FileName As String)
    If Success Then
        Dim OutputStream1 As OutputStream
        OutputStream1.InitializeToBytesArray(1000)
           
        '''''''''''''''''''''''''''''
        Dim b As Bitmap
        b = LoadBitmap(Dir,FileName)
        b = CreateScaledBitmap(b, 500, 500, True)
       
        b.WriteToStream(OutputStream1, 100, "PNG")
       
        '''''''''''''''''''''''''''''
        buffer = OutputStream1.ToBytesArray
      
        OutputStream1.Close

1 - Here Insert it as array of bytes (buffer) ?

        Dim bmpdata() As Byte = buffer
        Dim su As StringUtils
        img64 = su.EncodeBase64(bmpdata)
               
2 - Or Here Insert it as base64string (img64) ?

        ImageView1.Bitmap=b       
       
    Else
        ToastMessageShow("No image selected", True)
    End If
End Sub

Sub CreateScaledBitmap(Original As Bitmap, Width As Int, Height As Int, Filter As Boolean) As Bitmap
    Dim jo As JavaObject
    jo.InitializeStatic("android.graphics.Bitmap")
    Return jo.RunMethod("createScaledBitmap", Array (Original, Width, Height, Filter))
End Sub
 
Upvote 0
Top