resize method
Image
resize(
- int newWidth,
- int newHeight, {
- StbirPixelLayout pixelLayout = c.StbirPixelLayout.STBIR_RGB,
- StbirDataType dtype = c.StbirDataType.STBIR_TYPE_UINT8,
- StbirEdge edge = c.StbirEdge.STBIR_EDGE_CLAMP,
- StbirFilter filter = c.StbirFilter.STBIR_FILTER_DEFAULT,
- int? inputStride,
- int? outputStride,
Implementation
Image resize(
int newWidth,
int newHeight, {
c.StbirPixelLayout pixelLayout = c.StbirPixelLayout.STBIR_RGB,
c.StbirDataType dtype = c.StbirDataType.STBIR_TYPE_UINT8,
c.StbirEdge edge = c.StbirEdge.STBIR_EDGE_CLAMP,
c.StbirFilter filter = c.StbirFilter.STBIR_FILTER_DEFAULT,
int? inputStride,
int? outputStride,
}) {
inputStride ??= 0;
outputStride ??= 0;
final pOutPixels = c.stbir_resize(
ptr,
_width,
_height,
inputStride,
ffi.nullptr,
newWidth,
newHeight,
outputStride,
pixelLayout,
dtype,
edge,
filter,
);
if (pOutPixels == ffi.nullptr) {
final pReason = c.stbi_failure_reason();
throw MNNException("Failed to resize image: ${pReason.cast<Utf8>().toDartString()}");
}
return Image.fromPointer(
pOutPixels.cast(),
width: newWidth,
height: newHeight,
channels: _channels,
desiredChannels: _desiredChannels,
dtype: StbiDType.fromStbirDataType(dtype),
);
}