<?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; image</title>
	<atom:link href="http://blog.yoz.sk/tag/image/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>Lanczos Resampling With ActionScript</title>
		<link>http://blog.yoz.sk/2010/11/lanczos-resampling-with-actionscript/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=lanczos-resampling-with-actionscript</link>
		<comments>http://blog.yoz.sk/2010/11/lanczos-resampling-with-actionscript/#comments</comments>
		<pubDate>Wed, 10 Nov 2010 11:22:40 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[lanczos]]></category>
		<category><![CDATA[LanczosBitmapDataResizer]]></category>
		<category><![CDATA[resample]]></category>
		<category><![CDATA[resize]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=2576</guid>
		<description><![CDATA[It has been a while since I worked on some interesting library. But the day has come and here it is. Let me introduce you LanczosBitmapDataResizer class. Lanczos resampling is an interpolation method used to compute new values for sampled data. In resampling (resizing) images it is considered to be one of the best algorithms [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.yoz.sk/wp-content/uploads/lanczos.jpg" alt="" title="lanczos" width="200" height="100" class="alignleft size-full wp-image-2578" /></p>
<p>It has been a while since I worked on some interesting library. But the day has come <img src='http://blog.yoz.sk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  and here it is. Let me introduce you <a href="http://classes.yoz.sk/sk/yoz/image/LanczosBitmapDataResizer.as">LanczosBitmapDataResizer</a> class. <a href="http://en.wikipedia.org/wiki/Lanczos_resampling">Lanczos resampling</a> is an interpolation method used to compute new values for sampled data. In resampling (resizing) images it is considered to be one of the best algorithms at all. Lanczos is a convolution filters. That means a filter that for each output value moves the convolution functions point of origin to be centered on the output and then multiplies all the values in the input with the value of the convolution function (kernel) at that location and adds them together.</p>
<p><span id="more-2576"></span></p>
<p>The most common lanczos filter size is 3. It means that each output pixel is defined by its +- 3 pixel box. The kernel function than looks something like this:</p>
<pre class="brush: plain; title: ; notranslate">3*sin(pi*x)*sin(pi*x/3)/(pi*pi*x*x)</pre>
<p>While there is a lot of iterations and computing within my <a href="http://classes.yoz.sk/sk/yoz/image/LanczosBitmapDataResizer.as">algorithm</a>, I ivite you all to help me optimize the code.</p>
<p><script type="text/javascript" src="http://wonderfl.net/blogparts/dLf0/js"></script>
<p class="ttlBpWonderfl" style="width: 465px; margin: 0; text-align: right; font-size: 11px;"><a href="http://wonderfl.net/c/dLf0" title="Lanczos Resampling">Lanczos Resampling &#8211; wonderfl build flash online</a></p>
<p>More sources:</p>
<ul>
<li><a href="http://stackoverflow.com/questions/943781/where-can-i-find-a-good-read-about-bicubic-interpolation-and-lanczos-resampling">Where can I find a good read about bicubic interpolation and Lanczos resampling?</a></li>
<li><a href="http://src.chromium.org/svn/trunk/src/skia/ext/image_operations.cc">Chromium image operations</a></li>
<li><a href="http://blog.yoz.sk/2010/01/how-to-resize-an-image-with-actionscript/">How to resize an image with ActionScript</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2010/11/lanczos-resampling-with-actionscript/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Quick tip: embedding in Flex</title>
		<link>http://blog.yoz.sk/2009/10/quick-tip-embedding-in-flex/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=quick-tip-embedding-in-flex</link>
		<comments>http://blog.yoz.sk/2009/10/quick-tip-embedding-in-flex/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 12:07:58 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[asset]]></category>
		<category><![CDATA[Class]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[embed]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[mxml]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=505</guid>
		<description><![CDATA[In Flex application, you can embed your assets into 3 places: ActionScript, MXML, CSS. To embed into ActionScript use following syntax: To embed into MXML use: To embed asset into CSS file use syntax: Embedding font to .as (.mxml): Read more about embedding assets into ActionScript best practices here. Read basics about embedding here.]]></description>
			<content:encoded><![CDATA[<p>In Flex application, you can embed your assets into 3 places: ActionScript, MXML, CSS. To embed into <strong>ActionScript</strong> use following syntax:</p>
<pre class="brush: as3; title: ; notranslate">[Embed(source=&quot;assets/image.png&quot;)]
public var imageClass:Class;

[Embed(source=&quot;assets/library.swf&quot;, symbol=&quot;symbol1&quot;)]
public var symbol1Class:Class;

// flash library symbol alternative
[Embed(source=&quot;assets/library.swf#symbol2&quot;)]
public var symbol2Class:Class;
</pre>
<p>To embed into <strong>MXML</strong> use:</p>
<pre class="brush: xml; title: ; notranslate">&lt;mx:Image source=&quot;@Embed('assets/image.png')&quot;/&gt;
&lt;mx:Image source=&quot;@Embed('assets/library.swf', symbol='symbol1')&quot;/&gt;
&lt;mx:Image source=&quot;@Embed('assets/library.swf#symbol2')&quot;/&gt;
&lt;mx:Button skin=&quot;{null}&quot;/&gt;
</pre>
<p>To embed asset into <strong>CSS</strong> file use syntax:</p>
<pre class="brush: css; title: ; notranslate">Button
{
    upSkin: Embed(source=&quot;assets/image.png&quot;);
    overSkin: Embed(source=&quot;assets/library.swf&quot;, symbol=&quot;symbol1&quot;);
    downSkin: Embed(source=&quot;assets/library.swf#symbol2&quot;);
    selectedUpSkin:ClassReference(null);
}

@font-face
{
    font-family: Copacetix;
    src: url(&quot;assets/copacetix.ttf&quot;);
    unicode-range:
        U+0020-U+0040, /* Punctuation, Numbers */
        U+0041-U+005A, /* Upper-Case A-Z */
        U+005B-U+0060, /* Punctuation and Symbols */
        U+0061-U+007A, /* Lower-Case a-z */
        U+007B-U+007E; /* Punctuation and Symbols */
}
</pre>
<p>Embedding font to .as (.mxml):</p>
<pre class="brush: as3; title: ; notranslate">[Embed(source=&quot;../arial.ttf&quot;, fontFamily=&quot;myArial&quot;)]
public static const FONT_ARIAL:Class;
public static const FONT_ARIAL_NAME:String = &quot;myArial&quot;;

[Embed(source=&quot;../fonts.swf&quot;, fontName=&quot;myCourier&quot;, fontWeight=&quot;bold|normal&quot;) ]
public static const FONT_COURIER:Class;
Font.registerFont(FONT_COURIER);

public function Test()
{
    var format:TextFormat = new TextFormat();
    format.font	= FONT_ARIAL_NAME;

    var tf:TextField = new TextField();
    tf.embedFonts = true;
    tf.defaultTextFormat = format;
}</pre>
<p>Read more about <a href="http://blog.yoz.sk/2009/10/embedding-assets-wisely/">embedding assets into ActionScript best practices here</a>. Read <a href="http://www.adobe.com/devnet/flex/quickstart/embedding_assets/">basics about embedding here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2009/10/quick-tip-embedding-in-flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bitmap, BitmapData, ByteArray&#8230;</title>
		<link>http://blog.yoz.sk/2009/10/bitmap-bitmapdata-bytearray/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=bitmap-bitmapdata-bytearray</link>
		<comments>http://blog.yoz.sk/2009/10/bitmap-bitmapdata-bytearray/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 12:26:40 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[Bitmap]]></category>
		<category><![CDATA[BitmapData]]></category>
		<category><![CDATA[ByteArray]]></category>
		<category><![CDATA[converting]]></category>
		<category><![CDATA[DisplayObject]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[Loader]]></category>
		<category><![CDATA[LoaderInfo]]></category>
		<category><![CDATA[url]]></category>
		<category><![CDATA[URLRequest]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=135</guid>
		<description><![CDATA[Lets see how to convert between Bitmap, BitmapData and ByteArray in few examples: DisplayObject to BitmapData BitmapData to Bitmap BitmapData to ByteArray URL (image) to ByteArray (asynchronous) URL (image) to BitmapData (asynchronous) ByteArray to BitmapData (asynchronous) DisplayObject to BitmapData. FYI DisplayObject is any visible object in flash (Sprite, MovieClip, Bitmap, UIComponent, Video etc&#8230;): BitmapData to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.yoz.sk/wp-content/uploads/bitmap_converting.png"><img src="http://blog.yoz.sk/wp-content/uploads/bitmap_converting-200x119.png" alt="bitmap_converting" title="bitmap_converting" width="200" height="119" class="alignleft size-medium wp-image-452" /></a></p>
<p>Lets see how to convert between Bitmap, BitmapData and ByteArray in few examples:</p>
<ul style="float:left;">
<li>DisplayObject to BitmapData</li>
<li>BitmapData to Bitmap</li>
<li>BitmapData to ByteArray</li>
<li>URL (image) to ByteArray (asynchronous)</li>
<li>URL (image) to BitmapData  (asynchronous) </li>
<li>ByteArray to BitmapData  (asynchronous) </li>
</ul>
<div style="clear:both;"></div>
<p><span id="more-135"></span></p>
<p>DisplayObject to BitmapData. FYI <a href="http://livedocs.adobe.com/flex/3/langref/flash/display/DisplayObject.html">DisplayObject is any visible object in flash</a> (Sprite, MovieClip, Bitmap, UIComponent, Video etc&#8230;):</p>
<pre class="brush: as3; title: ; notranslate">import flash.display.BitmapData;
var bitmapData:BitmapData = new BitmapData(button.width, button.height, false, 0xFFFFFF);
bitmapData.draw(button);
// result: bitmapData</pre>
<p>BitmapData to Bitmap:</p>
<pre class="brush: as3; title: ; notranslate">import flash.display.Bitmap;
var bitmap:Bitmap = new Bitmap(bitmapData);
// result: bitmap</pre>
<p>BitmapData to ByteArray. Requires jpeg / png or any other encoder. <a href="http://blog.yoz.sk/2009/10/actionscript-3-encoding-jpeg/">Read more about JPEG encoding here</a>:</p>
<pre class="brush: as3; title: ; notranslate">import mx.graphics.codec.JPEGEncoder;
import flash.utils.ByteArray;
var encoder:JPEGEncoder = new JPEGEncoder(90);
var byteArray:ByteArray = encoder.encode(bitmapData));
// result: byteArray</pre>
<p>URL (image) to ByteArray. Asynchronous operation:</p>
<pre class="brush: as3; title: ; notranslate">import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.events.Event;
import flash.net.URLRequest;
import flash.utils.ByteArray;

var loader:Loader = new Loader();
loader.load(new URLRequest(&quot;banner1.jpg&quot;));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderComplete);

private function loaderComplete(event:Event):void
{
    var loaderInfo:LoaderInfo = LoaderInfo(event.target);
    var byteArray:ByteArray = loaderInfo.bytes;
    // result: byteArray
}</pre>
<p>URL (image) to BitmapData. Asynchronous operation:</p>
<pre class="brush: as3; title: ; notranslate">import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.events.Event;
import flash.net.URLRequest;
import flash.display.BitmapData;

var loader:Loader = new Loader();
loader.load(new URLRequest(&quot;banner1.jpg&quot;));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderComplete);

private function loaderComplete(event:Event):void
{
    var loaderInfo:LoaderInfo = LoaderInfo(event.target);
    var bitmapData:BitmapData = new BitmapData(loaderInfo.width, loaderInfo.height, false, 0xFFFFFF);
    bitmapData.draw(loaderInfo.loader);
    // result: bitmapData
}</pre>
<p>ByteArray to BitmapData. Asynchronous operation:</p>
<pre class="brush: as3; title: ; notranslate">import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.events.Event;
import flash.display.BitmapData;

var loader:Loader = new Loader();
loader.loadBytes(byteArray);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderComplete);

private function loaderComplete(event:Event):void
{
    var loaderInfo:LoaderInfo = LoaderInfo(event.target);
    var bitmapData:BitmapData = new BitmapData(loaderInfo.width, loaderInfo.height, false, 0xFFFFFF);
    bitmapData.draw(loaderInfo.loader);
    // result: bitmapData
}</pre>
<p><a href="http://www.bytearray.org/?p=1089">Synchronous JPEG ByteArray to BitmapData can be found here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2009/10/bitmap-bitmapdata-bytearray/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ActionScript 3 encoding JPEG, alchemy</title>
		<link>http://blog.yoz.sk/2009/10/actionscript-3-encoding-jpeg/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=actionscript-3-encoding-jpeg</link>
		<comments>http://blog.yoz.sk/2009/10/actionscript-3-encoding-jpeg/#comments</comments>
		<pubDate>Fri, 09 Oct 2009 11:53:05 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[alchemy]]></category>
		<category><![CDATA[asynchronous]]></category>
		<category><![CDATA[Bitmap]]></category>
		<category><![CDATA[BitmapData]]></category>
		<category><![CDATA[ByteArray]]></category>
		<category><![CDATA[converting]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[jpeg]]></category>
		<category><![CDATA[JPEGEncoder]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=136</guid>
		<description><![CDATA[Lets assume you want to save an image (or any DisplayObject) from flash to disk, or upload to facebook etc. What you need is to encode your BitmapData into an Jpeg and send ByteArray raw data to be saved/uploaded. There are few ways how to do it. First, you can use original adobe mx.graphics.codec.JPEGEncoder. Sadly, [...]]]></description>
			<content:encoded><![CDATA[<p>Lets assume you want to save an image (or any DisplayObject) from flash to disk, or upload to facebook etc. What you need is to encode your BitmapData into an Jpeg and send ByteArray raw data to be saved/uploaded. There are few ways how to do it.</p>
<p>First, you can use original adobe mx.graphics.codec.JPEGEncoder. Sadly, this encoder is the slowest. There were attemps to make it faster by otpimizing code by <a href="http://www.bytearray.org/">bytearray.org</a>, that resulted into two times faster <a href='http://classes.yoz.sk/org/bytearray/images/JPEGEncoder.as'>org.bytearray.images.JPEGEncoder</a>. Usage is pretty simple:</p>
<p><span id="more-136"></span></p>
<pre class="brush: as3; title: ; notranslate">import org.bytearray.JPEGEncoder;

function encode():ByteArray
{
    var bitmapData:BitmapData = new BitmapData(this.width, this.height, false);
    bitmapData.draw(this);
    var encoder:JPEGEncoder = new JPEGEncoder(80);
    return encoder.encode(bitmapData);
}</pre>
<p>But not fast enough <img src='http://blog.yoz.sk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . Since Flash Player 10 introduced <a href="http://labs.adobe.com/technologies/alchemy/">alchemy</a> (compiled C and C++ code within flash apps), it was possible to use <a href='http://classes.yoz.sk/jpegencoder.swc'>optimized C++ encoder to do the work</a>. Encoding time is more than 30 times faster than the original JPEGEncoder, pretty cool huh? Code looks like this</p>
<pre class="brush: as3; title: ; notranslate">import cmodule.jpegencoder.CLibInit;

function encode():ByteArray
{
    var bitmapData:BitmapData = new BitmapData(this.width, this.height, false);
    bitmapData.draw(this);
    var init:CLibInit = new CLibInit();
    var lib:Object = init.init();
    var byteArray:ByteArray = new ByteArray();
    var byteArrayOut:ByteArray = new ByteArray();
    byteArray = bitmapData.getPixels(bitmapData.rect);
    byteArray.position = 0;
    lib.encode(byteArray, byteArrayOut, bitmapData.width, bitmapData.height, 80);
    return byteArrayOut;
}</pre>
<p>You can also run your encoding in asynchronous mode&#8230; Read more and see tests here:</p>
<ul>
<li><a href="http://segfaultlabs.com/blog/post/asynchronous-jpeg-encoding">Alchemy &#8211; asynchronous jpeg encoding</a></li>
<li><a href="http://www.websector.de/blog/2009/06/21/speed-up-jpeg-encoding-using-alchemy/">Speed up JPEG encoding using Alchemy</a></li>
<li><a href="http://labs.adobe.com/technologies/alchemy/">Alchemy technology</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2009/10/actionscript-3-encoding-jpeg/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

