AS3/FP9 - 调整精灵大小

发布于 2024-08-08 18:24:38 字数 447 浏览 1 评论 0原文

我已将尺寸为 3264x2448 的 JPG 加载到 Sprite 中。如何按比例调整它的大小以允许我将 Sprite 绘制到 BitmapData 对象中(在 CS3/Flash Player 9 中高度或宽度限制为 2880)。我的目标是使用 Soulwire [DisplayUtils][1] 创建缩略图。这是与其他较小的精灵一起正常工作的代码:

var bmpd:BitmapData = new BitmapData(jpgSprite.width, jpgSprite.height, true, 0x00FFFFFF);
bmpd.draw( jpgSprite );

var thumb:Bitmap = DisplayUtils.createThumb( bmpd, 100, 100, Alignment.MIDDLE, true);
addChild( thumb );

感谢您的建议。

I've loaded a JPG with dimensions 3264x2448 into a Sprite. How can I resize it proprtionally to allow meto draw the Sprite into a BitmapData object (which in CS3/Flash Player 9 is limited to 2880 height or width). My goal is to use the Soulwire [DisplayUtils][1] to create a thumbnail. Here is the code that works fine with other, smaller, Sprites:

var bmpd:BitmapData = new BitmapData(jpgSprite.width, jpgSprite.height, true, 0x00FFFFFF);
bmpd.draw( jpgSprite );

var thumb:Bitmap = DisplayUtils.createThumb( bmpd, 100, 100, Alignment.MIDDLE, true);
addChild( thumb );

thanks for your suggestions.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

感性不性感 2024-08-15 18:24:38

我想使用矩阵来缩小它可能会成功。不过我还没有测试过代码。

var w:Number = 3264;
var h:Number = 2448;
var scale:Number = w / 2880;
var bmpd:BitmapData = new BitmapData(2880, h / scale, true, 0x00FFFFFF);
var matrix:Matrix = new Matrix();
matrix.createBox(scale, scale)
bmpd.draw(jpgSprite, matrix);

I guess using a matrix to scale it down might do the trick. I haven't tested the code though.

var w:Number = 3264;
var h:Number = 2448;
var scale:Number = w / 2880;
var bmpd:BitmapData = new BitmapData(2880, h / scale, true, 0x00FFFFFF);
var matrix:Matrix = new Matrix();
matrix.createBox(scale, scale)
bmpd.draw(jpgSprite, matrix);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文