Example usage for android.media CameraProfile getJpegEncodingQualityParameter

List of usage examples for android.media CameraProfile getJpegEncodingQualityParameter

Introduction

In this page you can find the example usage for android.media CameraProfile getJpegEncodingQualityParameter.

Prototype

public static int getJpegEncodingQualityParameter(int quality) 

Source Link

Document

Returns a pre-defined still image capture (jpeg) quality level used for the given quality level in the Camera application for the first back-facing camera on the device.

Usage

From source file:com.android.camera.manager.ThumbnailViewManager.java

private byte[] covertYuvDataToJpeg(byte[] data, int yuvWidth, int yuvHeight, int imageFormat) {
    byte[] jpeg;//from w ww.jav  a2  s.c o  m
    Rect rect = new Rect(0, 0, yuvWidth, yuvHeight);
    // TODO: the yuv data from native must be NV21 or YUY2.
    YuvImage yuvImg = new YuvImage(data, imageFormat, yuvWidth, yuvHeight, null);
    ByteArrayOutputStream outputstream = new ByteArrayOutputStream();
    int jpegQuality = CameraProfile.getJpegEncodingQualityParameter(CameraProfile.QUALITY_HIGH);
    yuvImg.compressToJpeg(rect, jpegQuality, outputstream);
    jpeg = outputstream.toByteArray();
    return jpeg;
}