I'm trying to figure out if I can use the HardwareBuffer.USAGE_GPU_SAMPLED_IMAGE flag in my ImageReader constructor:
val format = ImageFormat.PRIVATE // or ImageFormat.YUV_420_888
val imageReader = ImageReader.newInstance(
width,
height,
format,
MAX_IMAGES,
HardwareBuffer.USAGE_GPU_SAMPLED_IMAGE // <-- this one
)
To find out if that is supported, I am using the HardwareBuffer.isSupported method:
val supportsGpuFlag = HardwareBuffer.isSupported(
width,
height,
???, // <-- what do I put here?
1,
HardwareBuffer.USAGE_GPU_SAMPLED_IMAGE // <-- check if GPU is supported
)
I am usually working with ImageFormat.YUV_420_888 images, but there are some applications where I can switch to ImageFormat.PRIVATE images which makes the pipeline significantly more efficient.
I guess ImageFormat.YUV_420_888 is equivalent to HardwareBuffer.YCBCR_420_888, but what is ImageFormat.PRIVATE equivalent to?
On my emulator I tested streaming PRIVATE images and check their HardwareBuffer format which yielded HardwareBuffer.RGB_565, but I'm guessing this is different from device to device and is probably HardwareBuffer.YCBCR_420_888 on most devices.
But how do I get that at runtime?
TL;DR: I want to get the HardwareBuffer format equivalent of ImageFormat.PRIVATE flag at runtime.