#Region Project Attributes
#ApplicationLabel: PerspectiveTransformation
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: 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.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim nativeMe As JavaObject
Dim bm1, bm2 As Bitmap
Private ImageView1 As ImageView
Private ImageView2 As ImageView
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("main")
nativeMe.InitializeContext
bm1.Initialize(File.DirAssets,"33RfN.png")
ImageView1.Bitmap = bm1
Log(bm1.Width)
Log(bm1.Height)
Dim source() As Float = Array As Float(100.0, 0.0, 400.0, 170.0, 375.0, 380.0, 0.0, 190.0)
ImageView2.Bitmap = nativeMe.RunMethod("perspectiveTransformation", Array(bm1, source))
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
#If Java
import android.graphics.Matrix;
import android.graphics.Bitmap;
public static Bitmap perspectiveTransformation(Bitmap bitmap, float[] src)
{
Matrix matrix = new Matrix();
float[] dst = new float[] {
0,
0,
bitmap.getWidth(),
0,
bitmap.getWidth(),
bitmap.getHeight(),
0,
bitmap.getHeight()
};
// float[] src = new float[] {
// boundingQuad.topLeft.x,
// boundingQuad.topLeft.y,
// boundingQuad.topRight.x,
// boundingQuad.topRight.y,
// boundingQuad.bottomRight.x,
// boundingQuad.bottomRight.y,
// boundingQuad.bottomLeft.x,
// boundingQuad.bottomLeft.y
// };
matrix.setPolyToPoly(src, 0, dst, 0, src.length >> 1);
return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
}
#End If