Wednesday, April 13, 2011

Smoothing resized distorted images in flex

Problem: Images when loaded into flex look blurred, distorted or poor quality.

Solution: Fixing the loaded images using smoothing .


Hi guys , i think we all come across the problem of loading images into flex and disappointed by the way they look blurred or distorted in flex. By default images loaded into flex are not smooth.
I have written a small function that can be called on "complete" event of image loader component and rest you dont need to worry it takes care all . Above picture shows how clean image looks after after applying smoothing code .It even works if the image is zoomed or resized later .


//Mxml starts here




//call this function from where ever you need Image Smoothing .Code by http://askmeflash.com
private function smoothImage(evt:Event):void{
var myBitmap:Bitmap = ((evt.target as Image).content as Bitmap);
if (myBitmap != null) {
myBitmap.smoothing = true;>
}
}
]]>








//mxml ends here


Source:

No comments:

Freelance