user96219
user96219

Reputation:

Adobe Flex image scaling quality

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

Answers (5)

tst
tst

Reputation: 3351

See this: Smoothing resized distorted images in flex

Upvotes: 8

Vladimir Tsvetkov
Vladimir Tsvetkov

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

Julio Perez
Julio Perez

Reputation: 1

set scaleContent property to true

Upvotes: 0

Rick J
Rick J

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

dirkgently
dirkgently

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

Related Questions