header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
Inder

Smoothing resized distorted images in flex
Posted On: 12/19/2009 10:13:44 AM


/ Views: 5747



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

Solution: Fixing the loaded images using smoothing .

Before Smoothing
After 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

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:local="*" xmlns:asd="asd.*" >
<mx:Script>

<![CDATA[
//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;>
}
}
]]>
</mx:Script>

<!--Usage: call complete="smoothImage(event) from image component ) -->

<mx:Image id="myId" source="a.jpg" x="400" width="350" height="350" complete="smoothImage(event)" />
<mx:Image id="img1" source="b.jpg" x="400" y="400" width="300" height="150" complete="smoothImage(event)" />
</mx:Application>

//mxml ends here



Members Login

Email  
Password
Forgot Password





New Features

  • Registered users can rate articles.
  • Registered users can accept answers.
  • Subscribe to articles.
  • Subscribe to any Question.

  • This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
    Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions