Making small images bigger
If you are like me you will totally take for granted that changing the size of an image in flex will scale its content… most of the time. I recently built an application where I had to use bitmap data to snapshot a control and then display it elsewhere in the application. Via the design constraints this image needed to slide across the screen while scaling to the appropriate size for the destination display location. When I started the project I was just changing the height, and with the maintiainAspectRation property set to true, this would scale the image down to the right size.
But as we got further into the application, we found that we also had some content that was being snapshoted that was smaller than the display area. We needed to make this content larger to fit the destination space. Through away all the bad thoughts about blowing up bitmap data and the pixelation of the display. Changing the height of the item would not make it scale larger. Of course I could use matrix translations to scale the pixel data (which I did) and then move it around.
But the important thing to remember here is that our image component has a scaleX and scaleY property. And setting the scale properties causes the data to grow or shrink exactly as expected. So next time you have to change the size of an image… remember that you are scaling and use the pixel dimensions to calculate the proper scale value. Save yourself the time trying to figure out why changing the height of the image wont scale the content, and just scale the content your self.
This has been a sanity check post from the Simeon Says Command Center. Thanks for listening.
27 Aug 2008 Simeon 0 comments
