Android Question KVS put image increases a lot the file size

ilan

Expert
Licensed User
Longtime User
Hi

I am using KVS to create a database with custom types and that also includes images.

I add the images with the putimages function in the kvs2 class the problem is that the db filesize get very big even if the jpg images are very small

A 60kb image make a 214kb db file.
A 1.6 mb image makes a db file size of 14mb.

How can i get the same filesize as the images i put?

Thank you
 

Alexander Stolte

Expert
Licensed User
Longtime User
i'm using this function before I upload it, I do not notice any negative, but this function is only a little bit different to yours

B4X:
'Converts an image to a bytes array (for BLOB fields).
Public Sub ImageToBytes(Image As Bitmap) As Byte()
    Dim out As OutputStream
    out.InitializeToBytesArray(0)
    Image.WriteToStream(out, 100, "JPEG")
    out.Close
    Return out.ToBytesArray
End Sub
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
i'm using this function before I upload it, I do not notice any negative, but this function is only a little bit different to yours

B4X:
'Converts an image to a bytes array (for BLOB fields).
Public Sub ImageToBytes(Image As Bitmap) As Byte()
    Dim out As OutputStream
    out.InitializeToBytesArray(0)
    Image.WriteToStream(out, 100, "JPEG")
    out.Close
    Return out.ToBytesArray
End Sub

Will it also work for b4j?

I am not sure i can choose the quality and file type when writing to stream on b4j.
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
Upvote 0
Top