#Region Service Attributes
#StartAtBoot: False
#ExcludeFromLibrary: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim NativeMe As JavaObject
End Sub
Sub Service_Create
'This is the program entry point.
'This is a good place to load resources that are not specific to a single activity.
NativeMe.InitializeContext
File.Copy(File.DirAssets, "1.jpg", File.DirInternal, "1.jpg")
End Sub
Sub Service_Start (StartingIntent As Intent)
Dim fn As String = File.Combine(File.DirInternal, "1.jpg")
Dim lstBMPinfo As Int = NativeMe.RunMethod("getBMPinfo", Array(fn))
Log(lstBMPinfo)
Dim area As Rect
area.Initialize(5, 5, 10, 10)
Dim bmp As Bitmap = NativeMe.RunMethod("getRegionBitmap", Array(fn, area))
End Sub
#if Java
import java.util.*;
import java.lang.*;
import java.io.File;
import android.graphics.*;
public List getBMPinfo(String path) {
//String path = dir + File.separatorChar + fn;
BA.Log(path);
BitmapRegionDecoder bitmapRegionDecoder = BitmapRegionDecoder
.newInstance(path, false);
// Get the width and height of the full image
int fullWidth = bitmapRegionDecoder.getWidth();
int fullHeight = bitmapRegionDecoder.getHeight();
List lst = new ArrayList();
lst.add(fullWidth);
lst.add(fullHeight);
return lst;
}
public Bitmap getRegionBitmap(String path, Rect area) {
Bitmap regionBitmap = null;
BitmapRegionDecoder bitmapRegionDecoder = BitmapRegionDecoder
.newInstance(path, false);
Rect regionRect = new Rect(area.left, area.top, area.right, area.bottom);
regionBitmap = bitmapRegionDecoder.decodeRegion(regionRect, null);
return regionBitmap;
}
#end if