Hello.
This is my first post to the forum, so please excuse me if i make any mistakes regarding the posting procedure.
I have a little app as a test in order to save a png file from the File.DirAssets directory in a SQLite table named Images and in a field named Image.
The saveImage Sub is the following:
(please note that this is called from a simple button and for example reasons each time the sub is triggered the table is deleted and a new single entry is posted)
The LoadImage Sub is the following:
(as with the SaveImage, this sub is called by a button)
The problem is in sub LoadImage and in line b.Initialize2(inputStream1)
The error in Log is
What am i doing wrong?
Thank you in advance
This is my first post to the forum, so please excuse me if i make any mistakes regarding the posting procedure.
I have a little app as a test in order to save a png file from the File.DirAssets directory in a SQLite table named Images and in a field named Image.
The saveImage Sub is the following:
Saving Sub:
Private Sub SaveImage
Private InputStream1 As InputStream
Private OutputStream1 As OutputStream
Private Buffer() As Byte
InputStream1 = File.OpenInput(File.DirAssets,"map.png")
OutputStream1.InitializeToBytesArray(1000)
File.Copy2(InputStream1,OutputStream1)
Buffer = OutputStream1.ToBytesArray
SQL1.ExecQuery("Delete from Images")
SQL1.ExecNonQuery2("INSERT INTO Images VALUES (?)", Array As Object(Buffer))
End Sub
(please note that this is called from a simple button and for example reasons each time the sub is triggered the table is deleted and a new single entry is posted)
The LoadImage Sub is the following:
LoadImage Sub:
Private Sub LoadImage
Private rs As ResultSet
rs = SQL1.ExecQuery("SELECT image from Images")
Do While rs.NextRow
Private Buffer() As Byte
Buffer = rs.GetBlob("Image")
Private inputStream1 As InputStream
inputStream1.InitializeFromBytesArray(Buffer,0,Buffer.Length)
Private b As Bitmap
b.Initialize2(inputStream1)
inputStream1.Close
Loop
End Sub
(as with the SaveImage, this sub is called by a button)
The problem is in sub LoadImage and in line b.Initialize2(inputStream1)
The error in Log is
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 66 (Main)
java.lang.RuntimeException: Error loading bitmap.
at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize2(CanvasWrapper.java:539)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:197)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:6597)
at android.view.View.performClickInternal(View.java:6574)
at android.view.View.access$3100(View.java:778)
at android.view.View$PerformClick.run(View.java:25885)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
What am i doing wrong?
Thank you in advance