Name
CRC.putImageData() — copies pixels from an ImageData into the canvas
Synopsis
void putImageData(ImageDatadata
, floatdx
, floatdy
, floatsx
, floatsy
, floatsw
, floatsh
)
Arguments
data
An ImageData object.
dx
,
dy
The coordinates of a
destination
point in the canvas. Pixels fromdata
will be copied to the canvas starting at this point. These arguments are not transformed by the current transformation matrix.sx
,
sy
,
sw
,
sh
These optional arguments specify a source rectangle within the ImageData. If specified, only the pixels within that rectangle will be copied to the canvas. If omitted, all pixels in the ImageData will be copied. If these arguments specify a rectangle that exceeds the bounds of the ImageData, the rectangle will be clipped to those bounds. Negative values for
sx
andsy
are allowed.
Description
putImageData()
copies a rectangular block of
pixels from an ImageData object onto the canvas. This is a low-level
pixel copy operation: the globalCompositeOperation
and globalAlpha
attributes are ignored as are the
clipping region, transformation matrix, and shadow-drawing
attributes.
One use for ImageData objects is as a “backing store” for a
canvas—saving a copy of the canvas
pixels in an ImageData object (using get
Image
Data()
) allows you to draw temporarily on
the canvas and then restore it to its original state with
putImageData()
.
See Also
Get Canvas Pocket Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.