There was a problem retrieving an image of a BLOB field that were stored by external programs, I am not able to recover in B4A, but the same database SQLite used in C # or PHP the image field is read normally., below is the routine I'm using:
.....
Sub ReadBlob
c = s.ExecQuery("SELECT myPhoto FROM catalog WHERE pk_product = 1")
c.Position = 0
Dim Buffer() As Byte 'declare an empty byte array
Buffer = c.GetBlob("myPhoto")
Dim InputStream1 As InputStream
InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
Dim Bitmap1 As Bitmap
Bitmap1.Initialize2(InputStream1) ' *.......... error at this point
InputStream1.Close
ListView1.AddTwoLinesAndBitmap("test","test",Bitmap1)
c.Close
End Sub
error message with:
LogCat connected to: emulator-5554
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
main_readblob (java line: 410)
java.lang.RuntimeException: Error loading bitmap.
at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize2(CanvasWrapper.java:521)
at com.manoelneto.texana.main._readblob(main.java:410)
at com.manoelneto.texana.main._activity_create(main.java:341)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at com.manoelneto.texana.main.afterFirstLayout(main.java:102)
at com.manoelneto.texana.main.access$000(main.java:17)
at com.manoelneto.texana.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
.....
Sub ReadBlob
c = s.ExecQuery("SELECT myPhoto FROM catalog WHERE pk_product = 1")
c.Position = 0
Dim Buffer() As Byte 'declare an empty byte array
Buffer = c.GetBlob("myPhoto")
Dim InputStream1 As InputStream
InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
Dim Bitmap1 As Bitmap
Bitmap1.Initialize2(InputStream1) ' *.......... error at this point
InputStream1.Close
ListView1.AddTwoLinesAndBitmap("test","test",Bitmap1)
c.Close
End Sub
error message with:
LogCat connected to: emulator-5554
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
main_readblob (java line: 410)
java.lang.RuntimeException: Error loading bitmap.
at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize2(CanvasWrapper.java:521)
at com.manoelneto.texana.main._readblob(main.java:410)
at com.manoelneto.texana.main._activity_create(main.java:341)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at com.manoelneto.texana.main.afterFirstLayout(main.java:102)
at com.manoelneto.texana.main.access$000(main.java:17)
at com.manoelneto.texana.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)