How to change bitmap width and height in easeljs?

sathya picture sathya · Feb 11, 2013 · Viewed 20k times · Source

I am using easeljs to create HTML5 page. I have to load the images in canvas. How to change the width and height of the bitmap i am loading.

var img = new Image();  
img.src = image_path+images; // image from folder        
var loading_img = new createjs.Bitmap(img);  
stage.addChild(loading_img);

It just display the image in canvas, I try to use the

loading_img.sourceRect = { x:img.width/2, y:img.height/2, width:280, height:150 };

but it crop the image(280*150).

Thanks, Sathya

Answer

markE picture markE · Feb 11, 2013

Instead of adjusting the width and height, you would adjust scaleX and scaleY. To double the size of the image, you would do this:

loading_img.scaleX=2.0;
loading_img.scaleY=2.0;