Friday, April 2, 2010

Stage.quality property on FLEX and AIR

There are 2 source codes to resize bitmap data, one for AIR, one for FLEX.
The codes are same without .mxml head statement that is
%26lt;mx:WindowedApplication%26gt; or %26lt;mx:Application%26gt;.


The code are:
1. create TextField object and set ''XYZ'' into it with font-size:48px,bold.
2. create 2 BitmaData objects, one for initial drawing, one for resized result.
3. set stage.quality to ''BEST''. %26lt;-- this is current topic!
4. draw bitmap data with TextField.
5. resize above bitmap data to 1/3.
6. create Bitmap object from resized bitmap data.
7. display the bitmap on canvas.

By executing them,
FLEX environment makes the expected result that is good anti-aliased.
But AIR environment makes no good result.
then, I tried some patterns of stage.quality on FLEX and
I found the AIR result is equal to stage.quality=''HIGH'' on FLEX.
it seems the stage.quality ''BEST'' of AIR doesn't work?

Thank you for your help.

My environment:
Windows XP
Flex SDK 3.3 (FlexBuilder3)
Flash player 9 or 10
Air runtime 1.5.2?////same result with 1.5.1

program source code:

%26lt;?xml version=''1.0'' encoding=''utf-8''?%26gt;
%26lt;mx:WindowedApplication xmlns:mx=''http://www.adobe.com/2006/mxml'' layout=''absolute''%26gt;
%26lt;mx:Script%26gt;
?%26lt;![CDATA[
import mx.core.UIComponent;

private function sample(event:Event):void{
?var txtf:TextField = new TextField();
?txtf.htmlText = ''%26lt;FONT SIZE=\''48\''%26gt;%26lt;b%26gt;XYZ%26lt;/b%26gt;%26lt;/FONT%26gt;''

?var bmpCanvas:BitmapData = new BitmapData(txtf.textWidth, txtf.textHeight, true, 0x000000);
?var bmpResult:BitmapData = new BitmapData(txtf.textWidth, txtf.textHeight, true, 0x000000);
?
?stage.quality = StageQuality.BEST;
?bmpCanvas.draw(txtf);
?
?var myMatrix:Matrix = new Matrix();
?myMatrix.a = myMatrix.d = 1;
?myMatrix.scale(1/3, 1/3);
?bmpResult.draw(bmpCanvas, myMatrix, null, null, null, true);

?var bm:Bitmap = new Bitmap(bmpResult, PixelSnapping.ALWAYS, true);
?var ui:UIComponent = new UIComponent();
?ui.addChild(bm);
?cvs.addChild(ui);
}
?]]%26gt;
%26lt;/mx:Script%26gt;
%26lt;mx:Canvas x=''10'' y=''10'' width=''200'' height=''200'' backgroundColor=''#FFFFFF'' id=''cvs'' click=''sample(event)''%26gt;
%26lt;/mx:Canvas%26gt;
%26lt;/mx:WindowedApplication%26gt;

  • concealer makeup
  • No comments:

    Post a Comment