3dphotoshoot

diff src/android/MainActivity.java @ 9:d1b456d08713

texture matrix and video size from JNI
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 25 May 2015 05:27:26 +0300
parents 9fc7d52f578d
children dccbd7d65517
line diff
     1.1 --- a/src/android/MainActivity.java	Mon May 25 04:14:38 2015 +0300
     1.2 +++ b/src/android/MainActivity.java	Mon May 25 05:27:26 2015 +0300
     1.3 @@ -24,6 +24,8 @@
     1.4  
     1.5  	// old camera api (fallback)
     1.6  	private static Camera cam;
     1.7 +	private static Camera.Parameters params;
     1.8 +	private static int preview_width, preview_height;
     1.9  	private static SurfaceTexture surftex;
    1.10  
    1.11  	public static int start_video(int texid)
    1.12 @@ -49,10 +51,13 @@
    1.13  
    1.14  		cam = Camera.open(0);
    1.15  
    1.16 -		Camera.Parameters params = cam.getParameters();
    1.17 +		params = cam.getParameters();
    1.18  		params.set("orientation", "landscape");
    1.19  		cam.setParameters(params);
    1.20  
    1.21 +		preview_width = params.getPreviewSize().width;
    1.22 +		preview_height = params.getPreviewSize().height;
    1.23 +
    1.24  		try {
    1.25  			cam.setPreviewTexture(surftex);
    1.26  		}
    1.27 @@ -70,14 +75,18 @@
    1.28  	{
    1.29  		cam.stopPreview();
    1.30  		cam = null;
    1.31 +		params = null;
    1.32  		surftex = null;
    1.33  	}
    1.34  
    1.35 -	public static synchronized void update()
    1.36 +	public static synchronized void update(float [] matrix)
    1.37  	{
    1.38 -		if(cam != null && surftex != null && frame_pending) {
    1.39 -			surftex.updateTexImage();
    1.40 -			frame_pending = false;
    1.41 +		if(cam != null && surftex != null) {
    1.42 +			if(frame_pending) {
    1.43 +				surftex.updateTexImage();
    1.44 +				frame_pending = false;
    1.45 +			}
    1.46 +			surftex.getTransformMatrix(matrix);
    1.47  		}
    1.48  	}
    1.49  }