1 Reply Latest reply on May 24, 2010 2:14 AM by David_F57

    How to reduce resoluion of bitmapped image

    vineet osho Level 1

      Hello friends

                           i am taking the bitmapped of a canvas a having height 390 and width 234.using that code

       

                          var snapshot:ImageSnapshot = ImageSnapshot.captureImage(cnvParent);
                           var bdata:String = ImageSnapshot.encodeImageAsBase64(snapshot);

       

      and post the bitmap data to php end(server side) throug HTTP service.it creates an image of same resolution of 390x234. but now i want to send the image with resolution 200x150 resolution of same canvas having height 390 width 234.so can any body guides me wot kind of changes required in my code for this.


      Thanks And Regards

           Vineet osho.

        • 1. Re: How to reduce resoluion of bitmapped image
          David_F57 Level 5

          hi,

           

          The following process will return a resized image form a displayobject

           

           

           

          private function rescale(content:DisplayObject, width:int): BitmapData

          {

          var scale:Number=width/content.width;

          var bd : BitmapData = new BitmapData(content.width*scale,content.height*scale);

          var mt:Matrix=new Matrix();

          mt.scale(scale,scale);

          bd.draw(content,mt);

          return bd;

          }

          for instance if I have an image thats 1000*750 and I want the width to be 250
          var bd:BitmapData = rescale(image.content,250);
          with snapshot you would need to convert the bytearray data into a bitmap for the function to work.
          David.