3 Replies Latest reply on May 26, 2010 7:07 AM by David_F57

    Sending Scale of image in Byte array

    vineet osho

      Hello Friends

                         Please guide me how can i send yte array of my  bitmapped UIcopmonent with scale size 0.4.

      Actually my size of my UIComponet is 234X390 and i hv to send the  byte array to PHP end with size 90X150.

      this is almost 0.4 scale of image so how can i draw an image with  smaller size.please guide me.


                         when i usedthis code


                          var bmd:BitmapData = new  BitmapData(cnvParent.width,cnvParent.height,true,0xffffff);
                           var mt:Matrix=new Matrix();
                          var  jpgencoder:PNGEncoder = new PNGEncoder();
                           byteArray = jpgencoder.encode(bmd); 


                         it shows nothing after conversion to byte  array.Please help me out from this problem i mtotally confused



      Thanks and Regards

           Vineet osho

        • 1. Re: Sending Scale of image in Byte array
          David_F57 Level 5



          If you acknowledged the answers you where given to previous requests for help maybe calling people friend would sound more sincere. You where shown how to scale images already was that process not working ?




          • 2. Re: Sending Scale of image in Byte array
            vineet osho Level 1

            Hello David

                            Thanks alot for your reply.this time looking littlebit rude.i extreamly sorry if u mind my new discussion with same query.Actually your logic is perfect and working for all UIComponent but in my case its not working.thats why i again asked the question with scale factor.but now my problem has been solved.this time i need to take two UIComponent and two bitmapdata.

            Anyways Thanks alot  for your help.its truly helpful for me.and I ll remeber your lines and try to implement it in future.


            Thanks and regards

              Vineet Osho

            • 3. Re: Sending Scale of image in Byte array
              David_F57 Level 5



              the following is a full application that captures the canvas(when you click) then saves it to a file, so you can see the result.


              for this to work correctly(file save) you need to make sure your project compiler settings target flashplayer 10.0.0




              <?xml version="1.0" encoding="utf-8"?>

              <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">




              import mx.graphics.codec.PNGEncoder;


              protected function canvas1_mouseDownHandler(event:MouseEvent):void


              var pngenc:PNGEncoder = new PNGEncoder();

              var bmd:BitmapData = new  BitmapData(cnvs.width,cnvs.height,true,0xffffff);

              var mt:Matrix=new Matrix();



              var ba:ByteArray = new ByteArray()

              ba = pngenc.encode(bmd);


              var fi:FileReference = new FileReference();





              <mx:Canvas width="200" height="200" id="cnvs" mouseDown="canvas1_mouseDownHandler(event)">

              <mx:Button x="10" y="10" label="Button"/>

              <mx:CheckBox x="44" y="66" label="CheckBox"/>

              <mx:CheckBox x="44" y="125" label="CheckBox"/>