How does scaleX/scaleY work on Bitmap?
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?
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.
精彩评论