B bryon Member Licensed User Longtime User Oct 29, 2015 #1 What is the proper way to load a bitmap to ensure a corrupted file doesn't kill everything? Is a Try/Catch block acceptable in the release version and what are the consequences of this, if any? Thanks!
What is the proper way to load a bitmap to ensure a corrupted file doesn't kill everything? Is a Try/Catch block acceptable in the release version and what are the consequences of this, if any? Thanks!
R Roycefer Well-Known Member Licensed User Longtime User Oct 29, 2015 #2 A Try/Catch will be fine so long as you properly handle the failure to load the bitmap in the Catch block. Upvote 0
A Try/Catch will be fine so long as you properly handle the failure to load the bitmap in the Catch block.
Informatix Expert Licensed User Longtime User Oct 30, 2015 #4 bryon said: Thanks Roycefer! Click to expand... Note that you won't catch the most common error with bitmaps which is OutOfMemory. Upvote 0
bryon said: Thanks Roycefer! Click to expand... Note that you won't catch the most common error with bitmaps which is OutOfMemory.
R Roycefer Well-Known Member Licensed User Longtime User Oct 30, 2015 #5 That's true. Read this thread: https://www.b4x.com/android/forum/t...-to-check-memory-available.58925/#post-371102 for tips on how to avoid running into that. Upvote 0
That's true. Read this thread: https://www.b4x.com/android/forum/t...-to-check-memory-available.58925/#post-371102 for tips on how to avoid running into that.
Erel B4X founder Staff member Licensed User Longtime User Nov 1, 2015 #6 Informatix said: Note that you won't catch the most common error with bitmaps which is OutOfMemory Click to expand... LoadBitmap / LoadBitmapSample / Bitmap.Initialize / Bitmap.InitializeSample all catch the OOM error internally and downsample the image. The image will be downsampled up to 5 times (1 / 32 of the original size). If at that point the process runs out of memory then it is probably better to let the app crash and fix the issue as there isn't enough memory to do anything useful. Upvote 0
Informatix said: Note that you won't catch the most common error with bitmaps which is OutOfMemory Click to expand... LoadBitmap / LoadBitmapSample / Bitmap.Initialize / Bitmap.InitializeSample all catch the OOM error internally and downsample the image. The image will be downsampled up to 5 times (1 / 32 of the original size). If at that point the process runs out of memory then it is probably better to let the app crash and fix the issue as there isn't enough memory to do anything useful.
B bryon Member Licensed User Longtime User Nov 2, 2015 #7 This is good info to have. Thanks everyone. Upvote 0