Camera setPreviewTexture - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Camera setPreviewTexture method.

This code example shows how to use the following methods:setPreviewTexture, startPreview
    @Override 
    public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
        mCamera = Camera.open();
 
        try { 
            mCamera.setPreviewTexture(surface);
        } catch (IOException t) {
            android.util.Log.e("TextureView", "Cannot set preview texture target!", t);
        } 
 
        mCamera.startPreview();
    } 
 
    @Override 
    public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
        // Ignored, the Camera does all the work for us 
    } 
 
    @Override 
    public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setPreviewTexture
    // no-op 
  } 
 
  @Override 
  public void attach(Camera camera) throws IOException {
    camera.setPreviewTexture(surface);
  } 
 
  @Override 
  public void attach(MediaRecorder recorder) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
      // no-op 
    } 
    else { 
      throw new IllegalStateException(
                                      "Cannot use TextureView with MediaRecorder"); 
    } 
  } 
 
  @Override 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getParameters, release, setParameters, setPreviewTexture, startPreview
            if (mUseCameraInterface) {
                if (mCamera == null) {
                    mCamera = Camera.open();
                } 
                if (value == OFF) {
                    mParams = mCamera.getParameters();
                    mParams.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
                    mCamera.setParameters(mParams);
                    if (mode != STROBE) {
                        mCamera.stopPreview();
                        mCamera.release();
                        mCamera = null;
                        surfaceCreated = false;
                    } 
                    if (mWakeLock.isHeld())
                        mWakeLock.release();
                } else { 
                    if (!surfaceCreated) {
                        int[] textures = new int[1];
                        // generate one texture pointer and bind it as an 

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:release, setPreviewCallbackWithBuffer, setPreviewTexture, stopPreview
            mIsRunning = false;
        } finally { 
            mPreviewBufferLock.unlock();
        } 
 
        mCamera.stopPreview();
        mCamera.setPreviewCallbackWithBuffer(null);
        return 0; 
    } 
 
    @CalledByNative 
    public void deallocate() { 
        if (mCamera == null)
            return; 
 
        stopCapture(); 
        try { 
            mCamera.setPreviewTexture(null);
            if (mGlTextures != null)
                GLES20.glDeleteTextures(1, mGlTextures, 0);

7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getParameters, setPreviewTexture, startPreview
        catch (Exception e) { } 
    } 
     
    public void startPreview(SurfaceTexture surfaceTexture) throws IOException
    { 
        camera.setPreviewTexture(surfaceTexture);
        surfaceTexture.setOnFrameAvailableListener(this);
        camera.startPreview();
        Camera.Parameters params = camera.getParameters();
        android.util.Log.d("hikar","hfov=" + params.getHorizontalViewAngle() +
                                " vfov=" + params.getVerticalViewAngle());
    } 
     
    public void stopPreview() 
    { 
        camera.stopPreview();
        releaseCamera(); 
    } 
     
    public void releaseCamera() 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setPreviewTexture, startPreview
    @Override 
    public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
        mCamera = Camera.open();
 
        try { 
            mCamera.setPreviewTexture(surface);
        } catch (IOException t) {
            android.util.Log.e("TextureView", "Cannot set preview texture target!", t);
        } 
 
        mCamera.startPreview();
    } 
 
    @Override 
    public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
        // Ignored, the Camera does all the work for us 
    } 
 
    @Override 
    public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getParameters, setParameters, setPreviewTexture, startPreview
        // Open the camera 
        openCamera(width, height);
 
        // Start the camera 
        mStartCaptureTime = SystemClock.elapsedRealtime();
        mCamera.startPreview();
        mIsOpen = true;
    } 
 
    public void getCurrentFrame() { 
        if (checkNewFrame()) { 
            if (mStartCaptureTime > 0 && SystemClock.elapsedRealtime() - mStartCaptureTime > 2000) {
                // Lock white-balance and exposure for effects 
                Log.i("CC", "Locking white-balance and exposure!");
                Camera.Parameters params = mCamera.getParameters();
                params.setAutoWhiteBalanceLock(true);
                params.setAutoExposureLock(true);
                //mCamera.setParameters(params); 
                mStartCaptureTime = 0;
            } 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getParameters, setParameters, setPreviewTexture, startPreview
 
    } 
 
    public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
        mCamera = Camera.open(Camera.getNumberOfCameras()-1);
        Camera.Parameters parameters = mCamera.getParameters();
        parameters.setPreviewSize(imgW, imgH);
        mCamera.setParameters(parameters);
 
        try { 
            mCamera.setPreviewTexture(surface);
            mCamera.startPreview();
        } catch (IOException ioe) {
            // Something bad happened 
        } 
    } 
 
    public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
        // Ignored, Camera does all the work for us 
    } 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getParameters, setParameters, setPreviewTexture, startPreview
        // Open the camera 
        openCamera(width, height);
 
        // Start the camera 
        mStartCaptureTime = SystemClock.elapsedRealtime();
        mCamera.startPreview();
        mIsOpen = true;
    } 
 
    public void getCurrentFrame() { 
        if (checkNewFrame()) { 
            if (mStartCaptureTime > 0 && SystemClock.elapsedRealtime() - mStartCaptureTime > 2000) {
                // Lock white-balance and exposure for effects 
                Log.i("CC", "Locking white-balance and exposure!");
                Camera.Parameters params = mCamera.getParameters();
                params.setAutoWhiteBalanceLock(true);
                params.setAutoExposureLock(true);
                //mCamera.setParameters(params); 
                mStartCaptureTime = 0;
            } 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addCallbackBuffer, getParameters, setDisplayOrientation, setParameters, setPreviewDisplay
		return mFrameHeight;
	} 
 
	public void setPreview() throws IOException { 
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
			mCamera.setPreviewTexture(new SurfaceTexture(10));
		else 
			mCamera.setPreviewDisplay(null);
	} 
 
	public void surfaceChanged(SurfaceHolder _holder, int format, int width,
			int height) {
		Log.i(TAG, "surfaceCreated");
		if (mCamera != null) {
			Camera.Parameters params = mCamera.getParameters();
			mFrameWidth = width;
			mFrameHeight = height;
 
			List<Size> supportedPreviewSizes = params
					.getSupportedPreviewSizes();

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Camera setPreviewTexture Questions & Answers:

setPreviewTexture Method Overview
Sets the SurfaceTexture to be used for live preview.
See Code Examples for other Android Camera Methods: