使用AS3 Flex的调整图像 [英] Resize images in Flex using as3

查看:198
本文介绍了使用AS3 Flex的调整图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我加载使用装载机的图像。一旦加载,我可以用得到位图数据位图(event.target.loader.content).bitmapData

I am loading an image using a Loader. Once loaded, I can get the bitmap data using Bitmap(event.target.loader.content).bitmapData.

不过由于我装是相当大的图像(2000×1600左右),我想,以减少大小和可能创建一个新的更小的位图200或300像素宽,有点像缩略图。

However since the images I am loading are quite large (around 2000 x 1600), I would like to reduce the size and create a new smaller bitmap maybe 200 or 300 pixels wide, sort of like a thumbnail.

我认为它与创建一个新的的BitmapData 与新的大小。但是我不能够得到那个工作正常。

I think it has to do with creating a new BitmapData with the new size. However I am not able to get that working properly.

任何想法?

推荐答案

没测试过,但是这应该给你一个想法:

Not tested, but this should give you an idea:

public function scaleBitmap(src: BitmapData, ratio: Number): BitmapData
{
    var bmd: BitmapData = new BitmapData(src.width * ratio, src.height * ratio);
    var m: Matrix = new Matrix();   
    m.scale(ratio, ratio);
    bmd.draw(src, m);
    return bmd;
}

这篇关于使用AS3 Flex的调整图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆