Example usage for android.graphics PixelFormat JPEG

List of usage examples for android.graphics PixelFormat JPEG

Introduction

In this page you can find the example usage for android.graphics PixelFormat JPEG.

Prototype

int JPEG

To view the source code for android.graphics PixelFormat JPEG.

Click Source Link

Usage

From source file:gov.nasa.arc.geocam.geocam.CameraActivity.java

public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
    Camera.Parameters parameters = mCamera.getParameters();

    int wDiff = w;
    int hDiff = h;

    int realWidth = w, realHeight = h;

    List<Camera.Size> sizes = Reflect.CameraParameters.getSupportedPreviewSizes(parameters);
    if (sizes != null) {
        for (Camera.Size size : sizes) {
            int tempWDiff = Math.abs(size.width - w);
            int tempHDiff = Math.abs(size.height - h);

            if ((tempWDiff + tempHDiff) < (wDiff + hDiff)) {
                wDiff = tempWDiff;//from   w ww.  j  a v  a 2  s. c o  m
                hDiff = tempHDiff;
                realWidth = size.width;
                realHeight = size.height;
            }
        }
    }

    parameters.setPreviewSize(realWidth, realHeight);
    parameters.setPictureFormat(PixelFormat.JPEG);
    mCamera.setParameters(parameters);
    mCamera.startPreview();
}