<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jozef Chúťka&#039;s blog &#187; ResizeEvent</title>
	<atom:link href="http://blog.yoz.sk/tag/resizeevent/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.yoz.sk</link>
	<description>My life, my work</description>
	<lastBuildDate>Tue, 31 Jan 2012 12:40:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>SmoothImage Class (update)</title>
		<link>http://blog.yoz.sk/2010/01/smoothimage-class/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=smoothimage-class</link>
		<comments>http://blog.yoz.sk/2010/01/smoothimage-class/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 15:54:28 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[Bitmap]]></category>
		<category><![CDATA[BitmapData]]></category>
		<category><![CDATA[ImageResizer]]></category>
		<category><![CDATA[ResizeEvent]]></category>
		<category><![CDATA[ResizeMath]]></category>
		<category><![CDATA[SmoothImage]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=955</guid>
		<description><![CDATA[While Flex uses bilinear resizing method when scaling images (event for Bitmap.smoothing() method), you won&#8217;t be able to get nice results when downscaling more than 2 times. Inspired by ImageResizer class I have also created SmoothImage Class. This object extends mx.Image and uses ImageResizer.bilinearIterative() class in order to generate smoother resized results. In following example [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.yoz.sk/wp-content/uploads/smoothImage1-200x101.jpg" alt="" title="smoothImage" width="200" height="101" class="alignleft size-medium wp-image-963" /></p>
<p>While Flex uses bilinear resizing method when scaling images (event for Bitmap.smoothing() method), you won&#8217;t be able to get nice results when downscaling more than 2 times. Inspired by <a href="http://blog.yoz.sk/2010/01/how-to-resize-an-image-with-actionscript/">ImageResizer class</a> I have also created SmoothImage Class. This object extends mx.Image and uses ImageResizer.bilinearIterative() class in order to generate smoother resized results.</p>
<p><span id="more-955"></span></p>
<p style="clear:both;">In following example mx.Image, <a href="http://cookbooks.adobe.com/post_A_better_smooth_Image_control-9409.html">SmoothImage</a> and <a href="http://classes.yoz.sk/sk/yoz/image/SmoothImage.as">sk.yoz.image.SmoothImage</a> used to demonstrate resizing original 1024x679px image.</p>
<p><iframe src="http://blog.yoz.sk/examples/smoothImage/" width="100%" height="300" style="border:none;"></iframe></p>
<p><a href="http://classes.yoz.sk/sk/yoz/image/SmoothImage.as">sk.yoz.image.SmoothImage</a> class:</p>
<pre class="brush: as3; title: ; notranslate">package sk.yoz.image
{
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.geom.Matrix;
    import flash.geom.Point;

    import mx.controls.Image;

    import sk.yoz.math.ResizeMath;

    public class SmoothImage extends Image
    {
        protected var _resizeFunction:String = &quot;bilinearIterative&quot;;
        protected var _iterationMultiplier:Number = 2;
        protected var resizedBitmap:Bitmap;

        public function SmoothImage()
        {
            super();
        }

        [Bindable(event=&quot;resizeFunctionChanged&quot;)]
        [Inspectable(category=&quot;Other&quot;, defaultValue=&quot;bilinearIterative&quot;,
            enumeration=&quot;bilinear,bilinearIterative&quot;)]
        public function set resizeFunction(value:String):void
        {
            if(value == resizeFunction)
                return;
            _resizeFunction = value;
            resizeBitmap();
        }

        public function get resizeFunction():String
        {
            return _resizeFunction;
        }

        [Bindable(event=&quot;iterationMultiplierChanged&quot;)]
        public function set iterationMultiplier(value:Number):void
        {
            if(value == iterationMultiplier)
                return;

            _iterationMultiplier = value;
            resizeBitmap();
        }

        public function get iterationMultiplier():Number
        {
            return _iterationMultiplier;
        }

        override protected function updateDisplayList(unscaledWidth:Number,
            unscaledHeight:Number):void
        {
            super.updateDisplayList(unscaledWidth, unscaledHeight);
            resizeBitmap();
        }

        protected function resizeBitmap(... rest):void
        {
            if(!width || !height || !content)
                return;

            if(resizedBitmap &amp;&amp; resizedBitmap.parent)
                resizedBitmap.parent.removeChild(resizedBitmap);

            resizedBitmap = new Bitmap(resizedBitmapData);
            addChild(resizedBitmap);
            content.visible = false;
        }

        protected function get resizeMethod():String
        {
            return maintainAspectRatio ? ResizeMath.METHOD_LETTERBOX
                : ResizeMath.METHOD_RAW;
        }

        protected function get resizedBitmapData():BitmapData
        {
            var bitmapData:BitmapData;

            if(content is Bitmap)
            {
                bitmapData = Bitmap(content).bitmapData
            }
            else
            {
                bitmapData = new BitmapData(content.width / content.scaleX,
                    content.height / content.scaleY, true, 0);
                bitmapData.draw(content);
            }

            var dimensions:Point = ResizeMath.newDimensions(
                new Point(bitmapData.width, bitmapData.height),
                new Point(width, height), resizeMethod, true);

            return ImageResizer[resizeFunction](bitmapData, dimensions.x,
                dimensions.y, resizeMethod, true, iterationMultiplier);
        }
    }
}</pre>
<p>Update (Jan 27, 2010): in sk.yoz.image.SmoothImage</p>
<p>Update (Jun 14, 2010): in sk.yoz.image.SmoothImage</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2010/01/smoothimage-class/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

