This source file includes following definitions.
- fromImage
- handle
- rotate180
- close
- finalize
package com.example.helloandroidcamera2;
import android.graphics.ImageFormat;
import android.media.Image;
import java.nio.ByteBuffer;
public class HalideYuvBufferT implements AutoCloseable {
static {
System.loadLibrary("HelloAndroidCamera2");
}
private long mHandle;
public static HalideYuvBufferT fromImage(Image image) {
if (image.getFormat() != ImageFormat.YUV_420_888) {
throw new IllegalArgumentException("src must have format YUV_420_888.");
}
Image.Plane[] planes = image.getPlanes();
long handle = AndroidBufferUtilities.allocNativeYuvBufferT(
image.getWidth(),image.getHeight(),
planes[0].getBuffer(), planes[0].getRowStride(), planes[1].getBuffer(),
planes[2].getBuffer(), planes[1].getPixelStride(), planes[1].getRowStride());
return new HalideYuvBufferT(handle);
}
public HalideYuvBufferT(long handle) {
mHandle = handle;
}
public long handle() {
return mHandle;
}
public void rotate180() {
AndroidBufferUtilities.rotateNativeYuvBufferT180(mHandle);
}
@Override
public void close() {
if (mHandle != 0L) {
AndroidBufferUtilities.freeNativeYuvBufferT(mHandle);
mHandle = 0L;
}
}
@Override
protected void finalize() {
close();
}
}