Reputation:
I have an image viewer I wrote in Flex that scales the size of the image you're currently viewing based on the size of the browser. This is what the tag looks like:
<mx:Image id="img"
maintainAspectRatio="true"
source="{horizontalList.selectedItem.image}-large.jpg"
height="100%"
horizontalCenter="0"
horizontalAlign="center"
top="5"
width="{horizontalList.width}"
updateComplete="onImageChange()"
click="onImgClick()"
/>
The original image size is always larger than the area of the browser, and unfortunately, Flex doesn't appear to be doing a very good job of downscaling the image. In fact, HTML in IE does a much better job if I use it's image tag. Is there a "quality" setting for scaling in Flex that I'm missing?
Thanks.
Upvotes: 5
Views: 10201
Reputation: 3013
Learn about the Flash Smoothing Issue I discovered few years ago and I blogged about. Basically, images that have an odd dimension(s) fail to be smoothed.
To fix this issue use the following snippet:
var smoothBitmapData : BitmapData = new BitmapData(
loadedBitmap.width + (loadedBitmap.width % 2),
loadedBitmap.height + (loadedBitmap.height % 2),
true, 0x00FF0000);
smoothBitmapData.draw(loadedBitmap, null, null, null, null, true);
smoothBitmap = new Bitmap(smoothBitmapData, PixelSnapping.NEVER, true);
Upvotes: 1
Reputation: 2703
try to set the width and height of the control to the dimensions of the image and set the scaleContent property to true
Upvotes: 0
Reputation: 111120
This is a spot of bother with Flex 3 -- using an image in a list control. You have to be very careful to get the scaling right.
Why not try playing around with different combinations of scaleContent
and maintainAspectRatio
properties of Image
controls?
Here's a tutorial on scaling Images.
Upvotes: 0