Android Question Convert Bitmap to Blob

Guenter Becker

Active Member
Licensed User
Hi, hope your are fine.
In my Gallery I have png and jpg, jpeg or other type of pictures.
Taken one of these pictures via ContentChooser I do not know the picture type because they might be created by different media like the camera or a paint app o.s.o.
Therefore in the ContentChooser function I use 'image/*" for the file selection. This works fine.
If I like to convert the taken picture to a byte array to store it in a database blob column I run into the problem to specify the unknown picture type to choose the correct 'WriteToStream' command for converting.

But how is it possible to detect the picture typ or will this never mind for converting and I can use JPEG as standard?

Converting image 2 blob there are different commands like:
  • bmp.WriteToStream(OutputStream1, 100, "PNG")
  • bmp.WriteToStream(OutputStream1, 90, "JPEG")
Part of ContenChooser Function:
Dim cc As ContentChooser
    cc.Show("image/*", "Bitte Bild wählen:")
    Wait For CC_Result (Success As Boolean, Dir As String, FileName As String)

convert image to blob:
    Dim bmp As Bitmap = imvImage.Bitmap
    Dim OutputStream1 As OutputStream
    bmp.WriteToStream(OutputStream1, 90, "JPEG")
    Dim Buffer() As Byte = OutputStream1.ToBytesArray

Thankyou for your assisstance.


Licensed User
Longtime User
will this never mind for converting and I can use JPEG as standard?
It does not matter.
It does not matter. Look at post #2 here: Use its code
By the way, Mr. Becker you look good in that picture. Covid has not affected you at all. Keep it up.
Upvote 1

Similar Threads