Question

Here's the situation : on my stage, I have a Bitmap object that references a BitmapData object. My Bitmap object is fullscreen, so 1366x768.

On the other hand, I have a function (from a library so I can't edit it) that returns a BitmapData with a new picture. That picture is 640x480, and the function is called every second.

And here's the problem : I can't find a way to scale the returned picture to fullscreen. I tried with a Matrix and the .draw method but that do nothing.

Here's some code :

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);

With this code, the new picture is correctly displayed but in it's original size : 640x480 and the rest of the screen is blank.

Thanks in advance for your help !

Was it helpful?

Solution

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);

Just tried with different sizes, but it worked for me. But I use AS3, not AS2.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top