SORU
20 Mart 2009, Cuma


HTML tuvalden getPixel?

Belirli bir konuma bir renk elde etmek için HTML Tuval bir nesne sorgu yapmak mümkün mü?

CEVAP
20 Mart 2009, Cuma


W3C belgelerindeki pixel manipulation ilgili bir bölüm var.

Burada an example on how to invert an image:

// Get the CanvasPixelArray from the given coordinates and dimensions.
var imgd = context.getImageData(x, y, width, height);
var pix = imgd.data;

// Loop over each pixel and invert the color.
for (var i = 0, n = pix.length; i < n; i  = 4) {
    pix[i  ] = 255 - pix[i  ]; // red
    pix[i 1] = 255 - pix[i 1]; // green
    pix[i 2] = 255 - pix[i 2]; // blue
    // i 3 is alpha (the fourth element)
}

// Draw the ImageData at the given (x,y) coordinates.
context.putImageData(imgd, x, y);

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Elly

    Elly

    3 EKİM 2005
  • george sarintzotis

    george sarin

    2 Aralık 2007
  • pjtoohot

    pjtoohot

    15 NİSAN 2008