Example usage for android.graphics ImageFormat RAW12

List of usage examples for android.graphics ImageFormat RAW12

Introduction

In this page you can find the example usage for android.graphics ImageFormat RAW12.

Prototype

int RAW12

To view the source code for android.graphics ImageFormat RAW12.

Click Source Link

Document

Android 12-bit raw format

This is a single-plane, 12-bit per pixel, densely packed (in each row), unprocessed format, usually representing raw Bayer-pattern images coming from an image sensor.

Usage

From source file:Main.java

private static boolean checkAndroidImageFormat(Image image) {
    int format = image.getFormat();
    Plane[] planes = image.getPlanes();/*from   w w  w  .  j a  v a2  s .c  o  m*/
    switch (format) {
    case ImageFormat.YUV_420_888:
    case ImageFormat.NV21:
    case ImageFormat.YV12:
        return 3 == planes.length;
    case ImageFormat.RAW_SENSOR:
    case ImageFormat.RAW10:
    case ImageFormat.RAW12:
    case ImageFormat.JPEG:
        return 1 == planes.length;
    default:
        return false;
    }
}

From source file:freed.cam.apis.camera2.modules.PictureModuleApi2.java

private void saveImage(ImageHolder image) {
    int burstcount = parameterHandler.Burst.GetValue() + 1;
    String f;// w w w .  j  ava  2  s.  c  o  m
    if (burstcount > 1)
        f = cameraUiWrapper.getActivityInterface().getStorageHandler()
                .getNewFilePath(appSettingsManager.GetWriteExternal(), "_" + imagecount);
    else
        f = cameraUiWrapper.getActivityInterface().getStorageHandler()
                .getNewFilePath(appSettingsManager.GetWriteExternal(), "");
    File file = null;
    imagecount++;
    switch (image.getImage().getFormat()) {
    case ImageFormat.JPEG:
        file = new File(f + ".jpg");
        process_jpeg(image.getImage(), file);
        break;
    case ImageFormat.RAW10:
        file = new File(f + ".dng");
        process_rawWithDngConverter(image, DngProfile.Mipi, file);
        break;
    case ImageFormat.RAW12:
        file = new File(f + ".dng");
        process_rawWithDngConverter(image, DngProfile.Mipi12, file);
        break;
    case ImageFormat.RAW_SENSOR:
        file = new File(f + ".dng");
        if (appSettingsManager.getDevice() == Devices.Moto_X2k14
                || appSettingsManager.getDevice() == Devices.OnePlusTwo)
            process_rawWithDngConverter(image, DngProfile.Mipi16, file);
        else
            process_rawSensor(image, file);
        break;
    }
    internalFireOnWorkDone(file);
    isWorking = false;
    changeCaptureState(CaptureStates.image_capture_stop);
    if (burstcount == imagecount) {
        finishCapture(captureBuilder);
    }
}

From source file:freed.cam.apis.camera2.modules.PictureModuleApi2.java

private void SetBurst(int burst) {
    try {/* w ww. java 2s  . c  o m*/
        Log.d(TAG, "Set Burst to:" + burst);
        previewSize = cameraHolder.getSizeForPreviewDependingOnImageSize(
                cameraHolder.map.getOutputSizes(ImageFormat.YUV_420_888), cameraHolder.characteristics,
                mImageWidth, mImageHeight);
        if (cameraUiWrapper.getFocusPeakProcessor() != null) {
            cameraUiWrapper.getFocusPeakProcessor().kill();
        }
        int sensorOrientation = cameraHolder.characteristics.get(CameraCharacteristics.SENSOR_ORIENTATION);
        int orientation = 0;
        switch (sensorOrientation) {
        case 90:
            orientation = 0;
            break;
        case 180:
            orientation = 90;
            break;
        case 270:
            orientation = 180;
            break;
        case 0:
            orientation = 270;
            break;
        }
        cameraHolder.CaptureSessionH.SetTextureViewSize(previewSize.getWidth(), previewSize.getHeight(),
                orientation, orientation + 180, false);
        SurfaceTexture texture = cameraHolder.CaptureSessionH.getSurfaceTexture();
        texture.setDefaultBufferSize(previewSize.getWidth(), previewSize.getHeight());
        previewsurface = new Surface(texture);

        cameraUiWrapper.getFocusPeakProcessor().Reset(previewSize.getWidth(), previewSize.getHeight());
        Log.d(TAG, "Previewsurface vailid:" + previewsurface.isValid());
        cameraUiWrapper.getFocusPeakProcessor().setOutputSurface(previewsurface);
        camerasurface = cameraUiWrapper.getFocusPeakProcessor().getInputSurface();
        cameraHolder.CaptureSessionH.AddSurface(camerasurface, true);

        if (picFormat.equals(KEYS.JPEG))
            mImageReader = ImageReader.newInstance(mImageWidth, mImageHeight, ImageFormat.JPEG, burst + 1);
        else if (picFormat.equals(CameraHolderApi2.RAW10))
            mImageReader = ImageReader.newInstance(mImageWidth, mImageHeight, ImageFormat.RAW10, burst + 1);
        else if (picFormat.equals(CameraHolderApi2.RAW_SENSOR))
            mImageReader = ImageReader.newInstance(mImageWidth, mImageHeight, ImageFormat.RAW_SENSOR,
                    burst + 1);
        else if (picFormat.equals(CameraHolderApi2.RAW12))
            mImageReader = ImageReader.newInstance(mImageWidth, mImageHeight, ImageFormat.RAW12, burst + 1);
        cameraHolder.CaptureSessionH.AddSurface(mImageReader.getSurface(), false);
        cameraHolder.CaptureSessionH.CreateCaptureSession();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    if (parameterHandler.Burst != null)
        parameterHandler.Burst.ThrowCurrentValueChanged(parameterHandler.Burst.GetValue());
}