Mega Code Archive

 
Categories / Flex / Graphics
 

Compare Two Bitmap Images

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="800">     <mx:Script>                      import mx.core.BitmapAsset;             private function compare():void {                 var bmpd1:BitmapData = new BitmapData(img1.width, img1.height);                 var bmpd2:BitmapData = new BitmapData(img2.width, img2.height);                 bmpd1.draw(img1)                 bmpd2.draw(img2);                 var diff:BitmapData = bmpd2.compare(bmpd1) as BitmapData;                 var bitmapAsset:BitmapAsset = new BitmapAsset(diff);                 img3.source = bitmapAsset;             }            </mx:Script>     <mx:Image id="img1" source="logo.jpg" height="200" width="200"/>     <mx:Image id="img2" source="logo.png" height="200" width="200"/>     <mx:Button click="compare()" label="compare"/>     <mx:Image id="img3"/> </mx:VBox> </mx:Application>