# toImage method

Future<Image> toImage (int width, int height)

Creates an image from this picture.

The picture is rasterized using the number of pixels specified by the given width and height.

Although the image is returned synchronously, the picture is actually rasterized the first time the image is drawn and then cached.

## Implementation

    Future<Image> toImage(int width, int height) {
      if (width <= 0 || height <= 0)
        throw new Exception('Invalid image dimensions.');
      return _futurize(
        (_Callback<Image> callback) => _toImage(width, height, callback)
      );
    }