I have the function setHighlight
for my game that draws an image to an in-memory canvas, highlights any pixels in the ImageData
object that aren't an rgba value of [0,0,0,0] to green; however, I want to store this newly created ImageData
object in my object, or "class", variable.
I have two object variables, one called parentResource and parentResourceHighlight.
parentResource is the original, unchanged Image
object. I want to store the edited ImageData
object returned from the setHighlight
function in the parentResourceHighlight variable, so it can later be drawn with the drawImage
function. How can I do this?
I know I can use putImageData
to draw the newly created data, but I need to use drawImage
instead. And as for as I know, an ImageData
object (which is returned by my function) does not work with it. Is there a way I can use putImageData
to draw the image and then copy that from the canvas bitmap into an actual Image
or draw-able object?
tl;dr "HTML5, can I create an Image object from an ImageData object?"
Thanks, I hope I made my question clear! If you are confused by any parts, please say so.