How to create an image from array of pixel colors? (Flash, Actionscript 3)
- by Ole Jak
I have a Width and Height parametr. I have been given an array of colors in such format: [r, g, b, a, r, g, b, a, r, g, b, a... etc]
Data can be acsessed by something like this
for(var y = 0; y < height; y++)
{
for(var x = 0; x < width; x++)
{
r = data[y*width + x + 0]
g = data[y*width + x + 1]
b = data[y*width + x + 2]
a = data[y*width + x + 3]
}
}
I want to paint that data on some sprite. How to do such thing?
BTW: I use Flash Builder for mxml+actionscript coding. So if it is easy for you you can give example using MXML (not todraw on some sprite but on some MXML component).