getImageDataUrl

Get a screenshot of the image rendered on the canvas.

Signatures

  •   Paramate.Viewport.getImageDataUrl( cb, type = 'image/png', encoderOptions = 0.92 )

Details

The function returns a data URL type representation (same as using canvas.toDataUrl() function) of the rendered image.

Example

 viewPort.getImageDataUrl( function( dataUrl ){
   // Create image with snapshot of viewport
   document.getElementById('snapshot').innerHTML = "<img src='" + dataUrl + "' alt='snapshot'>";
 });
 

Parameters

cb

Callback function to be called with the data URL as argument.

type

The image format. Default = image/png.

encoderOptions

A Number between 0 and 1 indicating the image quality to use for image formats that use lossy compression such as image/jpeg and image/webp. Default = 0.92

Return value

No return value, but calls the callback function with the data URL