Jump to content

What is the best way to Capture a BitmapData?


clark
 Share

Recommended Posts

I have a situation where I am constructing multiple assets with BitmapData objects. 

 

Lets say that I have 50 of these Objects.   What I am doing now is creating a BitmapData, passing it over to a Phaser.Image and voila. 

 

However, I am concerned of needing to create and store that many BitmapData objects and it leaves a whole book of performance questions which I do not really understand. 

 

I am aware of toDataURI and I use it for capturing a users Input to send over the network.  I appreciate that.  However, a base64 string is really not what I want? It would require even more processing steps to return it back into a texture. 

Does anyone have any ideas how to convert a BitmapData into some kind of Texture I can apply to a Phaser.Image and then discard the BitmapData afterwards? Is there any benefit here from doing so?

 

Thanks!

 

Link to comment
Share on other sites

I doubt there is a significant difference in the amount of memory taken up by a decoded Image object vs. a Canvas (which is what a BitmapData is). Unless you're starting to really struggle on-device or something then maybe just use the BMDs directly for your Sprite textures. Just be sure to recycle them, so if you know a bunch of Sprites could share one then do so - and equally if you know one is dead and won't be needed again, flag it as such so another Sprite could use it.

 

You want to keep the total number of canvas objects created as low as possible, but only in the same way you want to keep the total number of Images loaded into memory as low as possible too.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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