Android Question Load sql blob data and display image on html page

metrick

Active Member
Licensed User
Longtime User
Ok, spend amount of time searching, but couldn't get answered.
Codes to read data from sql:
B4X:
                  Dim Buffer() As Byte 'declare an empty byte array
                            Buffer = cur.GetBlob("Img")
                            Dim InputStm As InputStream
                            InputStm.InitializeFromBytesArray(Buffer, 0, Buffer.Length)

              Dim Bmp As Bitmap
              Bmp.Initialize2(InputStm)
              InputStm.Close

'tag to display img:
<img src=Bmp style="width:120px;height:120px;">
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
As @DonManfred wrote you need to save it to a file:
B4X:
Dim out As OutputStream = File.OpenOutput(...)
out.WriteBytes(buffer, 0, buffer.length)
out.Close
You can save it to File.DirInternal.

B4X:
WebView.LoadHtml($"
<img src="file://${File.Combine(File.DirInternal, "1.png")}" style="width:120px;height:120px;"/>
"$)
 
Upvote 0
Top