fromYuvPlanes static method
Creates an Image from the specified YUV planes.
param yPlane A buffer that contains the Y plane. param uPlane A buffer that contains the U plane. param vPlane A buffer that contains the V plane. param yWidth The width, in pixels, of the Y plane. param yHeight The height, in pixels, of the Y plane. param uvPixelStride The pixel-level stride, in pixels, of the U and V planes. param uvRowStride The row-level stride, in pixels, of the U and V planes. param dstPixelFormat The pixel format into which to convert the input image. return The newly created document image. throws DocumentException An error has occurred during Document Library execution.
Implementation
static DocumentImage fromYuvPlanes(Uint8List? yPlane, Uint8List? uPlane, Uint8List? vPlane, int yWidth, int yHeight, int uvPixelStride, int uvRowStride, PixelFormat dstPixelFormat) {
DocumentImage documentImage = DocumentImage();
Pointer<UnsignedChar>? pYPlane;
if (yPlane != null) {
pYPlane = calloc.allocate<UnsignedChar>(yPlane.length);
pYPlane.cast<Uint8>().asTypedList(yPlane.length).setAll(0, yPlane);
}
Pointer<UnsignedChar>? pUPlane;
if (uPlane != null) {
pUPlane = calloc.allocate<UnsignedChar>(uPlane.length);
pUPlane.cast<Uint8>().asTypedList(uPlane.length).setAll(0, uPlane);
}
Pointer<UnsignedChar>? pVPlane;
if (vPlane != null) {
pVPlane = calloc.allocate<UnsignedChar>(vPlane.length);
pVPlane.cast<Uint8>().asTypedList(vPlane.length).setAll(0, vPlane);
}
try {
var err = documentSDK.id3DocumentImage_FromYuvPlanes(documentImage.handle, pYPlane ?? nullptr, yPlane?.length ?? 0, pUPlane ?? nullptr, uPlane?.length ?? 0, pVPlane ?? nullptr, vPlane?.length ?? 0, yWidth, yHeight, uvPixelStride, uvRowStride, dstPixelFormat.value);
if (err != DocumentError.success.value) {
documentImage.dispose();
throw DocumentException(err);
}
return documentImage;
} finally {
if (pYPlane != null) {
calloc.free(pYPlane);
}
if (pUPlane != null) {
calloc.free(pUPlane);
}
if (pVPlane != null) {
calloc.free(pVPlane);
}
}
}