我加载使用装载机的图像。一旦加载,我可以用得到位图数据位图(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的调整图像
发布评论