SOLVED:
B4A project using jRDC on local and remote servers just fine however I can't nut out how to successfully convert a retrieved blob from sqLite db and display image in an imageview.
the update/insert side is this:
returns job.success so the saving of image seems to work just fine.
The sqlite viewer displays the data as Ljava.lang.Object;@2e0fe16
The retrieval side is this:
..and the sub from dbRequestManager
The error I get is this:
The sqlite field type as BLOB does not seem to make any difference.
Im my mind I'm supposed to be feeding the "BytesToImage" sub with an array of bytes.
Appreciate some fresh eyes if possible...Thanks
B4A project using jRDC on local and remote servers just fine however I can't nut out how to successfully convert a retrieved blob from sqLite db and display image in an imageview.
the update/insert side is this:
B4X:
Dim req as dbRequestManager
Dim sSQL() As String
Dim Buffer() As Byte
'--load the test image
ivJobImg.Bitmap=LoadBitmapResize(Starter.shared,"image1.jpg",ivJobImg.Width, ivJobImg.Height,True)
If ivJobImg.IsInitialized Then
Buffer = req.ImageToBytes(ivJobImg.Bitmap)
End If
sSQL=Array As String(Array As Object(Buffer))
returns job.success so the saving of image seems to work just fine.
The sqlite viewer displays the data as Ljava.lang.Object;@2e0fe16
The retrieval side is this:
B4X:
Dim req as dbRequestManager
Dim Blob as object
Dim Buffer() As Byte
Dim ser As B4XSerializator
Blob = row(res.Columns.Get("Img"))
Buffer=ser.ConvertObjectToBytes(Blob)
ivJobImg.SetBackgroundImage(req.BytesToImage(Buffer)) '<--errors on this call
..and the sub from dbRequestManager
B4X:
'Converts a bytes array to an image (for BLOB fields).
Public Sub BytesToImage(bytes() As Byte) As Bitmap
Dim In As InputStream
In.InitializeFromBytesArray(bytes, 0, bytes.Length)
Dim bmp As Bitmap
bmp.Initialize2(In) '<-----Line 117---in dbRequestManager
Return bmp
End Sub
The error I get is this:
Error occurred on line: 117 (DBRequestManager)
java.lang.RuntimeException: Error loading bitmap.
at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize2(CanvasWrapper.java:539)
at b4a.RDCclient.dbrequestmanager._bytestoimage(dbrequestmanager.java:297)
The sqlite field type as BLOB does not seem to make any difference.
Im my mind I'm supposed to be feeding the "BytesToImage" sub with an array of bytes.
Appreciate some fresh eyes if possible...Thanks
Last edited: