html canvas pixel buffer -


I do not know the correct word, but in GTK I believe it was called a pixel buffer. You can copy all or some drawing area into pixbifes, and later you can dump pixbuf again on the screen, instead of going completely and rendering instead. I am implementing a menubar, and the menubar goes down and shows everything under it. However, it takes a few seconds to attract the whole canvas, so I was thinking that what seems to be a correct way of copying from the drop down menu, then when the drop down menu stops, it Print again on screen. I think this can be done with the context.getImageData () function, but I have read that it is very incompatible.

This is true, getImageData () is still very inefficient. But especially what you are trying to do, is a better start for this:

With the drawImage method of canvas reference, you can pass in an image , But you can also pass in another canvas. Create a temporary canvas that will never be added to the page:

  // is present only in javascript, not tempcanvas = document.createElement ('canvas') on the page; Tempcanvas.height = (normal canvas width); Tempcanvas.width = (normal canvas height);   

You can call tempcanvasContext.drawImage (normalCanvas, 0, 0) to take a snapshot of the current canvas before the drop down menu is ready. When the drop down menu disappears, you call it normalcanvasContext.drawImage (tempcanvas, 0, 0) to draw it back.

I hope this gives a good general idea, and it should be faster than getImageData . You can make it even more efficient by copying the exact part of the screen.

Comments