2 Replies Latest reply on Apr 25, 2010 9:08 PM by UbuntuPenguin

    BitmapImage scale

    UbuntuPenguin Level 4

      Noob Question Ahead.  You have been warned !


      With the new BitmapImage class , can it automatically scale down a much larger image to fit within its borders.  For example , my BitmapImage is 100 x 200.  Can I set the source to a bitmap that is 400 x 600 and have it automatically scale it down to fit in the 100 x 200 pixel space.


      Sincerely ,

        Ubuntu Penguin

        • 1. Re: BitmapImage scale
          David_F57 Level 5



          spark bitmapimage isn't as smart as mx image, scale simply stretches/shrinks the image to the bitmap image size. If you want to maintain the aspect ratio you need to correctly set the width/height to the correct aspect ratio.


          <s:BitmapImage id="img" width="100" height="100" fillMode="repeat" source="@Embed('image.jpg')"/>

          fillmode can be scale(stretch/shrink), clip(keep actual size), repeat(tiles the image).



          1 person found this helpful
          • 2. Re: BitmapImage scale
            UbuntuPenguin Level 4

            The reason for the bad behavior was because I wasn't specifying a size for my BitmapImage.  I didn't put a percent or pixel width/height , so it just went and did whatever.  Thanks for the help.