resize method

Image resize(
  1. int newWidth,
  2. int newHeight, {
  3. StbirPixelLayout pixelLayout = c.StbirPixelLayout.STBIR_RGB,
  4. StbirDataType dtype = c.StbirDataType.STBIR_TYPE_UINT8,
  5. StbirEdge edge = c.StbirEdge.STBIR_EDGE_CLAMP,
  6. StbirFilter filter = c.StbirFilter.STBIR_FILTER_DEFAULT,
  7. int? inputStride,
  8. 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),
  );
}