Adobe Flex 图像缩放质量

5

我编写了一个使用Flex编写的图像查看器,它根据浏览器的大小来缩放当前正在查看的图像的大小。标签如下:

<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()"
    />

原始图像的大小总是大于浏览器的区域,不幸的是,Flex 似乎在缩小图像方面做得并不好。实际上,在 IE 中使用其图像标记时,HTML 做得更好。我是否错过了 Flex 中的比例质量设置?

谢谢。

5个回答


1

了解我几年前发现并写博客介绍的Flash平滑问题。基本上,具有奇数尺寸的图像无法被平滑处理。

要解决此问题,请使用以下代码片段:

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);

0

将 scaleContent 属性设置为 true


0

使用 Flex 3 中的图像列表控件可能会遇到一些麻烦。你必须非常小心才能正确缩放。

为什么不尝试使用 Image 控件的不同组合的 scaleContentmaintainAspectRatio 属性进行调整?

这里有一个关于缩放图像的教程。


谢谢您的回复。我的图像控件不在列表控件内,只是使用一个单独的列表控件作为参考来调整自身大小。我阅读了您提供的教程链接,但它并没有真正讲到图像质量。我的基本问题是:在缩小图像时如何控制质量?默认情况下,Flex在缩小图像时似乎存在很多锯齿问题。谢谢。 - user96219

0
尝试将控件的宽度和高度设置为图像的尺寸,并将scaleContent属性设置为true。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接