Press on the image to return to the main documentation page.
VBBitmap
List of types:
SmartBitmap
SmartBitmap
Load a simple bitmap correctly
This is an 'Activity Object', it cannot be declared under Sub Process_Globals.
Permissions:
android.permission.WRITE_EXTERNAL_STORAGE
Events:
None
Members:
FreeMem
As
Double
FreeMem2
As
Long
Garbage
GlobalAllocSize
As
Long
[read
only]
GlobalFreedSize
As
Long
[read
only]
heapRemaining
As
Double
heapSize
As
Double
HowBig
(
Directory
As
String
,
Filename
As
String
)
As
String
loadbitmap
(
Directory
As
String
,
Filename
As
String
,
reqWidth
As
Integer
,
reqHeight
As
Integer
)
As
android
.
graphics
.
Bitmap
loadbitmap2
(
Directory
As
String
,
Filename
As
String
,
SampleSize
As
Integer
,
RGB565
As
Boolean
)
As
android
.
graphics
.
Bitmap
MaxMem
As
Double
nativeUsage
As
Double
Members description:
FreeMem
As
Double
returns free memory available from heap
double memoryAvailable = Runtime.getRuntime().maxMemory() - (heapSize - heapRemaining) - nativeUsage;
FreeMem2
As
Long
returns freeMemory
long freeMemory = (Runtime.getRuntime().maxMemory()) - (Debug.getNativeHeapAllocatedSize());
Garbage
Runs the Garbage Collector to free memory
Make sure your code is good first you are not initializing bitmaps aggressively
No amount of System.gc() calls will help a memory leak
You should split up the work and cache your data to file(s) and remove objects accordingly.
If you really need more memory you should run your java app with larger heap memory set
GlobalAllocSize
As
Long
[read
only]
returns getGlobalAllocSize;
GlobalFreedSize
As
Long
[read
only]
returns getGlobalFreedSize;
heapRemaining
As
Double
returns heapRemaining
Runtime.getRuntime().freeMemory();
heapSize
As
Double
returns totalMemory
Runtime.getRuntime().totalMemory();
HowBig
(
Directory
As
String
,
Filename
As
String
)
As
String
HowBig(String Directory, String Filename)
returns height/width as one combined string variable
loadbitmap
(
Directory
As
String
,
Filename
As
String
,
reqWidth
As
Integer
,
reqHeight
As
Integer
)
As
android
.
graphics
.
Bitmap
returns a simple bitmap
dont use file.dirassets ever, copy image over to another place from project
example: Activity.loadbitmap(mm.GetSafeBitmap(File.DirInternal,"/moon.jpg",Activity.height,Activity.width))
If this runs into memory problems, it's going to load a really low res image which will look bad
but it might not crash the app
loadbitmap2
(
Directory
As
String
,
Filename
As
String
,
SampleSize
As
Integer
,
RGB565
As
Boolean
)
As
android
.
graphics
.
Bitmap
loadbitmap2(String Directory, String Filename, Integer SampleSize, Boolean RGB565)
returns a safe sized bitmap
dont use file.dirassets ever, copy image over to another place from project
example: Activity.SetBackgroundImage(mm.loadbitmap2(File.DirInternal,"/moon.jpg",8))
SampleSize, can be 2, 4, ,6, 8,....16, 32...etc
RGB565=True will set options.inPreferredConfig = Config.RGB_565;
MaxMem
As
Double
returns MaxMemory
Runtime.getRuntime().maxMemory()
nativeUsage
As
Double
returns free memory available from heap
Debug.getNativeHeapAllocatedSize();
Top