HTML-doek putImageData() Metode
Voorbeeld
Die kode hieronder kopieer die pixeldata vir 'n gespesifiseerde reghoek op die doek met getImageData(), en plaas dan die beelddata terug op die doek met putImageData():
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.fillStyle = "red";
ctx.fillRect(10, 10, 50, 50);
function copy()
{
var imgData = ctx.getImageData(10, 10, 50, 50);
ctx.putImageData(imgData, 10, 70);
}
Blaaierondersteuning
Die nommers in die tabel spesifiseer die eerste blaaierweergawe wat die metode ten volle ondersteun.
Method | |||||
---|---|---|---|---|---|
putImageData() | Yes | 9.0 | Yes | Yes | Yes |
Definisie en gebruik
Die putImageData()-metode plaas die beelddata (van 'n gespesifiseerde ImageData-voorwerp) terug op die doek.
Wenk: Lees oor die getImageData() -metode wat die pixeldata vir 'n gespesifiseerde reghoek op 'n doek kopieer.
Wenk: Lees oor die createImageData() -metode wat 'n nuwe, leë ImageData-objek skep.
JavaScript-sintaksis
JavaScript-sintaksis: | konteks .putImageData( imgData,x,y, dirtyX,dirtyY,dirtyWidth,dirtyHeight ); |
---|
Parameterwaardes
Parameter | Description |
---|---|
imgData | Specifies the ImageData object to put back onto the canvas |
x | The x-coordinate, in pixels, of the upper-left corner of the ImageData object |
y | The y-coordinate, in pixels, of the upper-left corner of the ImageData object |
dirtyX | Optional. The horizontal (x) value, in pixels, where to place the image on the canvas |
dirtyY | Optional. The vertical (y) value, in pixels, where to place the image on the canvas |
dirtyWidth | Optional. The width to use to draw the image on the canvas |
dirtyHeight | Optional. The height to use to draw the image on the canvas |
❮ HTML-doekverwysing