Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 60fde9d2 authored by Lajos Molnar's avatar Lajos Molnar
Browse files

media: add crop rectangle to Image

Bug: 10706245
Change-Id: I9c9150bdef418fd96228addaa7c35f16e5e1ccff
parent 97affee6
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -14205,11 +14205,14 @@ package android.media {
  public abstract class Image implements java.lang.AutoCloseable {
    method public abstract void close();
    method public android.graphics.Rect getCropRect();
    method public abstract int getFormat();
    method public abstract int getHeight();
    method public abstract android.media.Image.Plane[] getPlanes();
    method public abstract long getTimestamp();
    method public abstract int getWidth();
    method public void setCropRect(android.graphics.Rect);
    field protected android.graphics.Rect mCropRect;
  }
  public static abstract class Image.Plane {
+30 −0
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package android.media;
import java.nio.ByteBuffer;
import java.lang.AutoCloseable;

import android.graphics.Rect;

/**
 * <p>A single complete image buffer to use with a media source such as a
 * {@link MediaCodec} or a
@@ -121,6 +123,34 @@ public abstract class Image implements AutoCloseable {
     */
    public abstract long getTimestamp();

    protected Rect mCropRect;

    /**
     * Get the crop rectangle associated with this frame.
     * <p>
     * The crop rectangle specifies the region of valid pixels in the image,
     * using coordinates in the largest-resolution plane.
     */
    public Rect getCropRect() {
        if (mCropRect == null) {
            return new Rect(0, 0, getWidth(), getHeight());
        } else {
            return new Rect(mCropRect); // return a copy
        }
    }

    /**
     * Set the crop rectangle associated with this frame.
     * <p>
     * The crop rectangle specifies the region of valid pixels in the image,
     * using coordinates in the largest-resolution plane.
     */
    public void setCropRect(Rect cropRect) {
        cropRect = new Rect(cropRect);  // make a copy
        cropRect.intersect(0, 0, getWidth(), getHeight());
        mCropRect = cropRect;
    }

    /**
     * Get the array of pixel planes for this Image. The number of planes is
     * determined by the format of the Image.