2 Replies Latest reply on Dec 18, 2009 9:23 PM by mina-s

    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
      <mx:WindowedApplication> or <mx:Application>.

      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". <-- 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:


      <?xml version="1.0" encoding="utf-8"?>
      <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
         import mx.core.UIComponent;

         private function sample(event:Event):void{
          var txtf:TextField = new TextField();
          txtf.htmlText = "<FONT SIZE=\"48\"><b>XYZ</b></FONT>"

          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;
          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();
      <mx:Canvas x="10" y="10" width="200" height="200" backgroundColor="#FFFFFF" id="cvs" click="sample(event)">

        • 1. Re: Stage.quality property on FLEX and AIR

          I'm having similar problem.


          To resize a bitmap, I change stage.quality to BEST, scale the image, then revert stage.quality to HIGH. The code when run in a flex application results in a super smooth scaled down image. But similar quality smoothing is not applied when run in Air application. It seems that AIR runtime doesn't go beyond quality.HIGH because even when set to quality.BEST, it's performance is similar to quality.HIGH in flex.


          Someone please help!

          1 person found this helpful
          • 2. Re: Stage.quality property on FLEX and AIR
            mina-s Level 1


            It may be good with UIComponent.

            for example...

            - stage.quality = StageQuality.BEST;

            - var bm:Bitmap = new Bitmap(<your base BitmapData>, PixelSnapping.AUTO, true);

            - var ui:UIComponent = new UIComponent();

            - ui.addChild(bm);

            - var matrix:Matrix = new Matrix();

            - matrix.scale(1/3, 1/3);

            - <your new BitmapData>.draw(ui, matrix);