1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.camera.processing.imagebackend; 18 19 import android.graphics.Rect; 20 21 import com.android.camera.app.OrientationManager; 22 import com.android.camera.one.v2.camera2proxy.ImageProxy; 23 import com.android.camera.one.v2.camera2proxy.TotalCaptureResultProxy; 24 import com.google.common.util.concurrent.ListenableFuture; 25 26 /** 27 * An image to be processed by the image backend. Contains an ImageProxy and 28 * parameters required to process the image. 29 */ 30 public class ImageToProcess { 31 public final ImageProxy proxy; 32 public final OrientationManager.DeviceOrientation rotation; 33 public final ListenableFuture<TotalCaptureResultProxy> metadata; 34 public final Rect crop; 35 36 /** 37 * @param proxy The underlying image to process. 38 * @param imageRotation The amount to rotate the image (after cropping). 39 * @param metadata The capture result metadata associated with this image. 40 * @param crop The crop region of the image to save. Note that this is in 41 * the coordinate-space of the original image, so the crop should 42 * be performed *before* any rotation, and a crop rectangle of 43 * (0, 0)-(proxy.width, proxy.height) is a no-op. 44 */ ImageToProcess(ImageProxy proxy, OrientationManager.DeviceOrientation imageRotation, ListenableFuture<TotalCaptureResultProxy> metadata, Rect crop)45 public ImageToProcess(ImageProxy proxy, OrientationManager.DeviceOrientation imageRotation, 46 ListenableFuture<TotalCaptureResultProxy> metadata, Rect crop) { 47 this.proxy = proxy; 48 this.rotation = imageRotation; 49 this.metadata = metadata; 50 this.crop = crop; 51 } 52 53 /** 54 * No crop. 55 * 56 * @param proxy The underlying image to process. 57 * @param imageRotation The amount to rotate the image (after cropping). 58 * @param metadata The capture result metadata associated with this image. 59 */ ImageToProcess(ImageProxy proxy, OrientationManager.DeviceOrientation imageRotation, ListenableFuture<TotalCaptureResultProxy> metadata)60 public ImageToProcess(ImageProxy proxy, OrientationManager.DeviceOrientation imageRotation, 61 ListenableFuture<TotalCaptureResultProxy> metadata) { 62 this(proxy, imageRotation, metadata, new Rect(0, 0, proxy.getWidth(), proxy.getHeight())); 63 } 64 } 65