Android Question Save app-generated bitmap to SQL?

DrownedBat

Member
Licensed User
Longtime User
Working on an app that creates bitmaps and haven't run across how to set the buffer to the image created. Most literature and forum threads focus on loading a bitmap from a file directory and loading the buffer from that. How can I load the bitmap my app has drawn into the buffer?

B4X:
Dim Buffer() As Byte
Dim OutputStream1 As OutputStream
OutputStream1.InitializeToBytesArray(1000)
Buffer=? (That new bitmap the app has drawn)
OutputStream1.WriteBytes(Buffer, 0, Buffer.Length)
 

mangojack

Expert
Licensed User
Longtime User
B4X:
'write image to database ...
Dim bmp As B4XBitmap= ImageView1.Bitmap  'or your bitmap ...

Dim OutputStream1 As OutputStream
OutputStream1.InitializeToBytesArray(1000)
bmp.WriteToStream(OutputStream1, 90, "JPEG")
Dim Buffer() As Byte = OutputStream1.ToBytesArray

oSQL.ExecNonQuery2("INSERT INTO myTable VALUES (NULL, ?)", Array As Object(Buffer))

this might be of interest ...
 
Last edited:
Upvote 0
Top