Hi all, i am currently working on a project at work that requires writing an application to test the cameras on this product, i am currently using the Camera2 and CameraEx2 class written by Erel, i need to use the following java code to rotate the preview screen, i've did some research and found this code online, i am trying to use it but i need to convert it to B4A, my understanding of Reflection and JavaObject library is very limitted, can anyone help me with this?
Thanks All.
Walter
B4X:
private void setSurfaceOrientation(){
if (textureView == null) {
return;
} else try {
{
Matrix matrix = new Matrix();
int rotation = getWindowManager().getDefaultDisplay().getRotation();
RectF textureRectF = new RectF(0, 0, 640, 480);
RectF previewRectF = new RectF(0, 0, textureView.getHeight(), textureView.getWidth());
float centerX = textureRectF.centerX();
float centerY = textureRectF.centerY();
if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
previewRectF.offset(centerX - previewRectF.centerX(), centerY - previewRectF.centerY());
matrix.setRectToRect(textureRectF, previewRectF, Matrix.ScaleToFit.FILL);
float scale = Math.max((float) 640 / 640, (float) 480 / 640);
matrix.postScale(scale, scale, centerX, centerY);
matrix.postRotate(90 * (rotation - 2), centerX, centerY);
}
textureView.setTransform(matrix);
}
} catch (Exception e) {
e.printStackTrace();
}
}
Thanks All.
Walter