Reputation: 24061
I have a bitmap in as3, I want its height to be 800, I want the width to be adjusted with the correct ratio so the image doesn't look squashed. How can I do this programatically in as3?
myImageBM.height = 800;
myImageBM.width = ??
Upvotes: 0
Views: 530
Reputation: 208
Simply:
myImageBM.height = 800;
myImageBM.scaleX = myImageBM.scaleY;
Hope you'll find this usefull!!
Upvotes: 2
Reputation: 11590
Try:
myImageBM.height = 800;
myImageBM.width = myImageBM.scaleY * myImageBM.width;
This is assuming you are just displaying it. For further processing of the image I would apply a matrix to it's bitmap data.
Of course if you are dealing with both portrait and landscape images it would be slightly more complicated, but the general idea is you set either height or width, then use the bitmap's scale properties to adjust the other dimension.
Upvotes: 0