Hi,
i am new with B4A and try to store a bitmap into a sqlite table.
The storage code seems to work corrrectly.
>>
Dim b() As Byte = ImageToBytes(xui.LoadBitmap(File.DirAssets, "bmw_bild_icon.png"))
SQL_1.ExecNonQuery2("INSERT INTO kfz VALUES (1, 'BMW 316 i compact')", Array As Object(b,1))
<<<
But when i try to get the image from the db, an error occurs .
>>
Dim puffer As Byte = Cursor.GetBlob("image")
Dim bild As B4XBitmap = BytesToImage(puffer) ---> Error: Types does not match
img_1.Background = bild
<<<
I use the given Sub:
>>>
Public Sub BytesToImage(bytes() As Byte) As B4XBitmap
Dim In As InputStream
In.InitializeFromBytesArray(bytes, 0, bytes.Length)
#if B4A or B4i
Dim bmp As Bitmap
bmp.Initialize2(In)
#else
Dim bmp As Image
bmp.Initialize2(In)
#end if
Return bmp
End Sub
<<<
What is wrong??
thanks in advance..
i am new with B4A and try to store a bitmap into a sqlite table.
The storage code seems to work corrrectly.
>>
Dim b() As Byte = ImageToBytes(xui.LoadBitmap(File.DirAssets, "bmw_bild_icon.png"))
SQL_1.ExecNonQuery2("INSERT INTO kfz VALUES (1, 'BMW 316 i compact')", Array As Object(b,1))
<<<
But when i try to get the image from the db, an error occurs .
>>
Dim puffer As Byte = Cursor.GetBlob("image")
Dim bild As B4XBitmap = BytesToImage(puffer) ---> Error: Types does not match
img_1.Background = bild
<<<
I use the given Sub:
>>>
Public Sub BytesToImage(bytes() As Byte) As B4XBitmap
Dim In As InputStream
In.InitializeFromBytesArray(bytes, 0, bytes.Length)
#if B4A or B4i
Dim bmp As Bitmap
bmp.Initialize2(In)
#else
Dim bmp As Image
bmp.Initialize2(In)
#end if
Return bmp
End Sub
<<<
What is wrong??
thanks in advance..