B4J Question How Change Byte() to Image

emexes

Expert
Licensed User
Longtime User
This example of reading an image from a SQL BLOB might be relevant:

https://www.b4x.com/android/forum/threads/how-to-click-a-button-to-select-an-image-and-determine-if-the-image-size-is-greater-than-600kb.165316/page-2#post-1013911

B4X:
Private Sub SeekBar1_ValueChanged (Value As Int, UserChanged As Boolean)
    Dim Cursor1 As Cursor = SQL1.ExecQuery("SELECT * FROM cakes")
    If Cursor1.RowCount > 0 Then
        If Value < Cursor1.RowCount Then
            Cursor1.Position = Value
        Else
            Cursor1.Position = Cursor1.RowCount - 1
        End If
    
        Dim CakePicture() As Byte = Cursor1.GetBlob("picture")

        Dim In As InputStream
        In.InitializeFromBytesArray(CakePicture, 0, CakePicture.Length)
        Dim bmp As Bitmap
        bmp.Initialize2(In)
        In.Close

        ImageView1.Bitmap = bmp
    End If
End Sub
 
Last edited:
Upvote 0
Top