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

  • Ammine Getahun

    Ammine Getah

    21 HAZİRAN 2011
  • Flash CS6 Video Tutorials for Beginners (Actionscript 3 Gaming)

    Flash CS6 Vi

    14 EYLÜL 2012
  • IGN

    IGN

    19 EYLÜL 2006