Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to resize a SpriteAsset without adding it to the display list?

I have an embedded image asset (with a scale9 grid), and I'm trying to get the bitmapdata when it's resized, but I can't seem to do this without adding it to the display list.

I try this:

spriteAsset.setActualSize(w,h);
spriteAsset.width = w;
bmd.draw(spriteAsset);

But when I then draw out the bitmapdata with graphics.beginBitmapFill(), I just get the original un-stretched image.

Any pointers? Or do I need to take 9 separate BitmapData images and make 9 separate bitmap fills?

Cheers, -Josh

like image 959
Sophistifunk Avatar asked Feb 02 '26 04:02

Sophistifunk


1 Answers

My experience taking BitmapData.draw() snapshots of scale9 assets has been that the scale9 is discarded, even if the asset has been added to the display list. This is a bug as far as I'm concerned, I don't know if it's been reported.

Aside from the scale9 disappointment, don't forget that BitmapData.draw can take a matrix parameter. By default it's null, meaning the identity matrix (no scale, rotation, etc). To take a snapshot of a transformed asset, you need to provide its transformation matrix...

bmd.draw(spriteAsset, spriteAsset.transform.matrix)

(Haven't double checked this stuff sorry, so ymmv.)

like image 107
aaaidan Avatar answered Feb 03 '26 18:02

aaaidan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!