Bitmap error

Smee

Well-Known Member
Licensed User
Longtime User
i have the following code snippet

B4X:
   If File.Exists(File.DirInternal & "/Jpegs/" ,Filename) Then
      Dim bmpImage As Bitmap
                bmpImage.Initialize(File.DirInternal & "/Jpegs/" ,Filename)
                .......
                .......
                .......
       end if

every so often a bitmap fails to load. There are only half a dozen or so and it is the same ones. They all used to load ok.

The error i get is the following
HTML:
main_initscrollview2 (B4A line: 678)

bmpImage.Initialize(File.DirInternal & "/Jpegs/" ,Filename)
java.lang.RuntimeException: Error loading bitmap.

   at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize2(CanvasWrapper.java:500)
   at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize(CanvasWrapper.java:491)
   at Akcent.Demo.main._initscrollview2(main.java:2828)
   at Akcent.Demo.main._directories_itemlongclick(main.java:2032)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:155)
   at anywheresoftware.b4a.objects.ListViewWrapper$2.onItemLongClick(ListViewWrapper.java:68)
   at android.widget.AbsListView.performLongPress(AbsListView.java:3143)
   at android.widget.AbsListView$CheckForLongPress.run(AbsListView.java:3093)
   at android.os.Handler.handleCallback(Handler.java:615)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:137)
   at android.app.ActivityThread.main(ActivityThread.java:4898)
   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:1008)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
   at dalvik.system.NativeStart.main(Native Method)
java.lang.RuntimeException: Error loading bitmap.
PackageAdded: package:com.viber.voip
** Service (aftercallinx) Create **
** Service (aftercallinx) Start **
** Service (aftercallinx) Destroy **
** Service (aftercallinx) Create **
** Service (aftercallinx) Start **
** Service (aftercallinx) Destroy **
** Service (aftercallinx) Create **
** Service (aftercallinx) Start **
** Service (aftercallalx) Create **
** Service (aftercallalx) Start **
** Service (aftercallinx) Destroy **
** Service (aftercallalx) Destroy **

I could replace the jpeg but it may happen again so i need to know why it is happening. i am overcoming it with try catch but it is not a solution.
 

Smee

Well-Known Member
Licensed User
Longtime User
It is a file i uploaded to the internet. it is only a small jpeg
 
Upvote 0

Smee

Well-Known Member
Licensed User
Longtime User
it is just an ftp download

FTP.DownLoadFile(File.DirInternal & "/Jpegs/","/Jpegs/",NextFileName,False)
 
Upvote 0

Smee

Well-Known Member
Licensed User
Longtime User
Yes and Yes. i am going to erase all the jpegs and re-download. As i said they used to display ok.
 
Upvote 0

Smee

Well-Known Member
Licensed User
Longtime User
ok i downloaded the files again and everything is fine. I do not know what has caused the error or how to effectively deal with it
 
Upvote 0
Top