Actionscript AS3-尝试调整位图数据的大小,但矩阵不';我不能改变任何事情

Actionscript AS3-尝试调整位图数据的大小,但矩阵不';我不能改变任何事情,actionscript,matrix,resize,bitmapdata,Actionscript,Matrix,Resize,Bitmapdata,情况是这样的:在我的舞台上,我有一个位图对象,它引用了BitmapData对象。我的位图对象是全屏的,所以是1366x768 另一方面,我有一个函数(来自一个库,所以我不能编辑它),它返回一个带有新图片的位图数据。该图片为640x480,函数每秒调用一次 问题是:我找不到办法将返回的图片缩放到全屏。我尝试了一个矩阵和.draw方法,但没有效果 下面是一些代码: var mat:Matrix = new Matrix(); mat.scale(0.52, 0.52); // I tried wit

情况是这样的:在我的舞台上,我有一个位图对象,它引用了BitmapData对象。我的位图对象是全屏的,所以是1366x768

另一方面,我有一个函数(来自一个库,所以我不能编辑它),它返回一个带有新图片的位图数据。该图片为640x480,函数每秒调用一次

问题是:我找不到办法将返回的图片缩放到全屏。我尝试了一个矩阵和.draw方法,但没有效果

下面是一些代码:

var mat:Matrix = new Matrix();
mat.scale(0.52, 0.52); // I tried with other values such as 2 but the picture stays the same
// scr_bmp is the BitmapData attached to the displayed Bitmap
// capt.bmp is the BitmapData returned by the function
// I tried without the new Rectangle but that doesn't change anything
scr_bmp.draw(capt.bmp, mat, null, null,new Rectangle(0, 0, 640, 480), true);
使用此代码,新图片将正确显示,但其原始大小为640x480,屏幕其余部分为空白

提前感谢您的帮助

hmmm

mat.scale(scr_bmp.width/capt.bmp.width,scr_bmp.height/capt.bmp.height);
var smallBitmap:Bitmap=new Bitmap(capt.bmp);
scr_bmp.fillRect(scr_bmp.rect,0x00808080);
scr_bmp.draw(smallBitmap,mat);

只是尝试了不同的尺寸,但它对我有效。但是我用的是AS3,不是AS2。

哦,我的天哪,非常感谢你!您的代码指出了我的代码中的一个错误,它阻止了矩阵正确工作。。。