1 | initial version |
I did this in Java and the code is like this:
ChangeCameraDisplay((int)(event.getX() + 500), (int)(event.getY() +500), getWindowManager().getDefaultDisplay().getWidth() * 2 ,getWindowManager().getDefaultDisplay().getHeight() * 2 );
while ChangeCameraDisplay function implementation is:
private void ChangeCameraDisplay(int left, int top, int stretchWidthAdd, int stretchHeightAdd)
{
cameraView.setTranslationX(-1 * left);
cameraView.setTranslationY(-1 * top);
//Get the width of the screen
int screenWidth = getWindowManager().getDefaultDisplay().getWidth();
int screenHeight = getWindowManager().getDefaultDisplay().getHeight();
//Get the SurfaceView layout parameters
android.view.ViewGroup.LayoutParams lp = cameraView.getLayoutParams();
//Set the width of the SurfaceView to the width of the screen
lp.width = screenWidth + stretchWidthAdd;
//Set the height of the SurfaceView to match the aspect ratio of the video
//be sure to cast these as floats otherwise the calculation will likely be 0
lp.height = screenHeight + stretchHeightAdd;
//Commit the layout parameters
cameraView.setLayoutParams(lp);
}
Explanation:
I moved the image by translate the X and Y.
I'm stretching the image by increasing the width and the height of the image on the current surface.
*I didn't change the surface size so the results look like zooming in.