Hello,
I am using the ImageUtilities from the 1.12 AcceleratedSurface library. I need to load two bitmaps that can sometimes be huge – 3000 x 2000 pixels or more.
When the bitmaps are too big I get the "java.lang.OutOfMemoryError". Sometimes the first bitmap will load properly, but the second bitmap will generate the out of memory error. I have the following code hoping that if the load bitmap fails it will generate an exception in which case I will try resizing the bitmap and loading again.
When the LoadScaledBitmap fails with an "out of memory error" it doesn't generate an exception, the app just closes with the "Sorry your app has closed" error message.
Do While (dflg = 0)
Try
bmw = imd.Get("Width") * rsz
bmh = imd.Get("Height") * rsz
bmSrc = iu.LoadScaledBitmap(File.DirDefaultExternal, fldSrc & "/" & FileSel.src, bmw, bmh, False)
bmLyr = iu.LoadScaledBitmap(File.DirDefaultExternal, fldSrc & "/" & FileSel.lyr, bmw, bmh, False)
dflg = 1
Catch
rsz = rsz - 0.1
If (rsz < 0.1) Then dflg = -1
End Try
Loop
Is there some way to detect these "out of memory" errors so that I can try again requesting a smaller resized bitmap?
Thanks,
Barry.