<?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>Eli Grey &#187; APNG</title>
	<atom:link href="http://eligrey.com/blog/post/tag/apng/feed" rel="self" type="application/rss+xml" />
	<link>http://eligrey.com/blog</link>
	<description>this instanceof Whitty</description>
	<lastBuildDate>Sat, 24 Dec 2011 22:58:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>APNG feature detection</title>
		<link>http://eligrey.com/blog/post/apng-feature-detection</link>
		<comments>http://eligrey.com/blog/post/apng-feature-detection#comments</comments>
		<pubDate>Wed, 04 Mar 2009 03:10:09 +0000</pubDate>
		<dc:creator>Eli</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[APNG]]></category>
		<category><![CDATA[Browsers]]></category>
		<category><![CDATA[feature detection]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JavaScript Libraries]]></category>
		<category><![CDATA[JavaScript Snippets]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://eligrey.com/?p=313</guid>
		<description><![CDATA[I have made a simple script that utilizes the HTML5 &#60;canvas&#62; API in only 9 functional lines of JavaScript to detect if a browser supports APNG images. It can be useful for deciding when to serve a client browser APNG images instead of GIF images. This will set the variable, apng_supported to true if the [...]]]></description>
			<content:encoded><![CDATA[<p>I have made a simple script that utilizes the HTML5 <code>&lt;canvas&gt;</code> API in only 9 functional lines of JavaScript to detect if a browser supports APNG images. It can be useful for deciding when to serve a client browser APNG images instead of GIF images.<br />
This will set the variable, <code>apng_supported</code> to <code>true</code> if the browser supports APNG.<br />
I have also created a <a href="http://code.eligrey.com/apng-detect/demo.html">demo</a> that uses this script.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #3366CC;">&quot;use strict&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> apngTest <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Image<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	ctx <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;canvas&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getContext</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;2d&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	apngTest.<span style="color: #000066;">onload</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		ctx.<span style="color: #660066;">drawImage</span><span style="color: #009900;">&#40;</span>apngTest<span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		self.<span style="color: #660066;">apng_supported</span> <span style="color: #339933;">=</span> ctx.<span style="color: #660066;">getImageData</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">data</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">3</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">===</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
	apngTest.<span style="color: #660066;">src</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACGFjVEwAAAABAAAAAcMq2TYAAAANSURBVAiZY2BgYPgPAAEEAQB9ssjfAAAAGmZjVEwAAAAAAAAAAQAAAAEAAAAAAAAAAAD6A+gBAbNU+2sAAAARZmRBVAAAAAEImWNgYGBgAAAABQAB6MzFdgAAAABJRU5ErkJggg==&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #006600; font-style: italic;">// frame 1 (skipped on apng-supporting browsers): [0, 0, 0, 255]</span>
	<span style="color: #006600; font-style: italic;">// frame 2: [0, 0, 0, 0]</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://eligrey.com/blog/post/apng-feature-detection/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>

