views:

102

answers:

1

I'm using a Bitmap cache that stores down a few Bitmaps. I called scaleX/scaleY on some of them, but the next time I retrieve from the cache, the Bitmap is screwed up. How does scaleX/scaleY work with Bitmap?

+2  A: 

This is really going to depend on your "cache" and how it's implemented, BUT it sounds like it is reusing Bitmap objects, and sharing BitmapData across them. Assuming that, I can tell you the following:

Bitmap is just a wrapper for BitmapData, so if you apply transformations to the Bitmap, those transformations will still apply if you attach a new BitmapData object to it. It sounds like the "cache" is not resetting the Bitmap objects before returning them to you (as a new object, but really its a recycled object)

SO it's not that scaleX and scaleY work any different on Bitmaps, it's that the "cache" is recycling them and not resetting them. Sounds like you will have to manually reset them, you could just set the scaleX/y to 1 for each "new" Bitmap you get.

To reiterate, I'm making assumptions about the cache, but this seems probable.

Tyler Egeto
Definitely seems like a valid possibility to me. It is the same thing I thought of first time, but since the question was not entirely clear I didn't waste my time. +1 to you for taking the time.
sberry2A
Lol, thanks. I almost didn't, it's like playing darts in the dark!
Tyler Egeto