Image Cropping in Flex

January 31, 2011

Even though there are many posts on this particular topic still there are many ???, then i thought may be i can write about it, so lets get started.

Lets do things in steps.

  1. Load Image in to Flex App
  2. Convert it to Bitmap and BitmapData objects.
  3. Crop Image using BitmapData object

1.Load Image in to Flex App

private var imageLoader:Loader = new Loader();

private function fnInit():void
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadImageComplete);
imageLoader.load(new URLRequest(“assets/flower.png”));

2.Convert it to Bitmap and BitmapData objects

private var bitmapImage:Bitmap;
private var bitmapDataImage:BitmapData;

//Event.COMPLETE eventHandler for Loader

private function loadImageComplete(e:Event):void
bitmapImage = Bitmap(;
bitmapDataImage = Bitmap(bitmapImage).bitmapData.clone();

3.Crop Image using BitmapData object
Read the rest of this entry »