Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
crooksy88

ImageLoader - How to create a bitmap of the cropped image area?

Recommended Posts

Hi,

 

I'm currently loading an image using the proportionalOutside and crop parameters:

 

queue.append( new ImageLoader(_loadedImageURL, {name:_imageName, estimatedBytes:2800, container:this, alpha:1, width:100, height:50, scaleMode:"proportionalOutside", crop:true}) );

 

If we imagine the full sized image that is loaded to be 200px wide by 50px high the image will crop off the left and right 50px. That is all good but if I get the width of the image I get 200px, not 100.

 

queue.getLoader(_imageName).rawContent.width); // 200

 

What I'm wanting to do is create a bitmap of the cropped area only, i.e. 100x50px

 

Would anyone know how I can access just this part of the image?

 

Thanks,

 

Mark

Link to post
Share on other sites

Sure, you should be able to just use BitmapData.draw() to draw the ContentDisplay to your BitmapData. Like:

 

var bd:BitmapData = new BitmapData(100, 50, true, 0x00FFFFFF);
bd.draw(yourImageLoader.content);
var bitmap:Bitmap = new Bitmap(bd);

 

Is that what you're looking for?

 

BitmapData docs from Adobe: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/BitmapData.html

Link to post
Share on other sites

Perfecto :-P . Certainly helps when you know what you're doing.

 

bd.draw(queue.getLoader(_imageName).content);

 

Thanks Jack.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×