toImageSync abstract method

Image toImageSync(
  1. int width,
  2. int height, {
  3. TargetPixelFormat targetFormat = TargetPixelFormat.dontCare,
})

Synchronously creates a handle to an image of this picture.

The returned image will be width pixels wide and height pixels high. The picture is rasterized within the 0 (left), 0 (top), width (right), height (bottom) bounds. Content outside these bounds is clipped.

The image object is created and returned synchronously, but is rasterized asynchronously. If the rasterization fails, an exception will be thrown when the image is drawn to a Canvas.

If a GPU context is available, this image will be created as GPU resident and not copied back to the host. This means the image will be more efficient to draw.

If no GPU context is available, the image will be rasterized on the CPU.

The targetFormat argument specifies the pixel format of the returned Image. If TargetPixelFormat.dontCare is specified, the pixel format will be chosen automatically based on the GPU capabilities.

Implementation

Image toImageSync(
  int width,
  int height, {
  TargetPixelFormat targetFormat = TargetPixelFormat.dontCare,
});