Jump to content

setPixel() and BitmapData.clear()


Recommended Posts

setPixel modifies the pixel array buffers directly. When that modification is done the bmd is flagged as dirty and the array buffer is copied over the bmd again. Methods like circle modify the bmd canvas object itself (using Canvas drawing primitives like arc and fillRect).


Basically if the bmd is updated via setPixel and you want that instantly reflected in the internal array then call update().

Equally though if you draw to the bmd via Circle and then want to draw over the top with setPixel you need to do: circle, update, setPixel.


The reason that methods like Circle don't automatically call update is that it's a quite expensive thing to do. If you don't actually need to use the pixel data then it's a waste of CPU updating it all each time you draw a primitive to the bmd. Also doing it this way means you can do lots of single canvas draw calls (like several circles and rects) and then when finished do one update call to refresh the pixel array.

Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...