Jump to content
Search Community

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

crooksy88 test
Moderator Tag

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 comment
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 comment
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.
×
×
  • Create New...