<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: HTML5&#8242;s canvas Part II: Pixel Manipulation</title>
	<atom:link href="http://beej.us/blog/2010/02/html5s-canvas-part-ii-pixel-manipulation/feed/" rel="self" type="application/rss+xml" />
	<link>http://beej.us/blog/2010/02/html5s-canvas-part-ii-pixel-manipulation/</link>
	<description>Tech and Programming Fun</description>
	<lastBuildDate>Tue, 07 Feb 2012 18:52:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: beej</title>
		<link>http://beej.us/blog/2010/02/html5s-canvas-part-ii-pixel-manipulation/comment-page-1/#comment-8269</link>
		<dc:creator>beej</dc:creator>
		<pubDate>Fri, 02 Dec 2011 19:21:23 +0000</pubDate>
		<guid isPermaLink="false">http://beej.us/blog/?p=581#comment-8269</guid>
		<description>&lt;a href=&quot;#comment-8213&quot; rel=&quot;nofollow&quot;&gt;@brock &lt;/a&gt; I&#039;m unaware of a way to get this low level data from the PNG, short of writing a PNG decoder in JS, and even then, my JS-fu isn&#039;t strong enough to know a way to get the binary data in JS.

By the time the data gets exposed, it&#039;s already abstracted. :-/</description>
		<content:encoded><![CDATA[<p><a href="#comment-8213" rel="nofollow">@brock </a> I&#8217;m unaware of a way to get this low level data from the PNG, short of writing a PNG decoder in JS, and even then, my JS-fu isn&#8217;t strong enough to know a way to get the binary data in JS.</p>
<p>By the time the data gets exposed, it&#8217;s already abstracted. :-/</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: brock</title>
		<link>http://beej.us/blog/2010/02/html5s-canvas-part-ii-pixel-manipulation/comment-page-1/#comment-8214</link>
		<dc:creator>brock</dc:creator>
		<pubDate>Thu, 10 Nov 2011 18:24:15 +0000</pubDate>
		<guid isPermaLink="false">http://beej.us/blog/?p=581#comment-8214</guid>
		<description>&lt;a href=&quot;#comment-8213&quot; rel=&quot;nofollow&quot;&gt;@brock &lt;/a&gt; 
I meant &quot;I can do it server side,...&quot;</description>
		<content:encoded><![CDATA[<p><a href="#comment-8213" rel="nofollow">@brock </a><br />
I meant &#8220;I can do it server side,&#8230;&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: brock</title>
		<link>http://beej.us/blog/2010/02/html5s-canvas-part-ii-pixel-manipulation/comment-page-1/#comment-8213</link>
		<dc:creator>brock</dc:creator>
		<pubDate>Thu, 10 Nov 2011 17:29:27 +0000</pubDate>
		<guid isPermaLink="false">http://beej.us/blog/?p=581#comment-8213</guid>
		<description>Is it possible to get the raw pixel value of an 8-bit indexed png, not the associated RGBA? I have images where the values (0-255) in the raw pixels have an actual data meaning. Depending on the time of year, the actual index palette changes, (so the displayed colors change) but not the 0-255 values in each pixel. I can do this client side, but with overhead which I don&#039;t want. 

What I want to do is a browser side calculation. So when a user mouses over an image, the x,y provides the pixel needed, and the 0-255 is extracted. This is then converted to a data value (using a know formula,) which can be displayed for the user (and of course, a coresponding lat long which can be determined since I know the outer lat/long bounds of the image)</description>
		<content:encoded><![CDATA[<p>Is it possible to get the raw pixel value of an 8-bit indexed png, not the associated RGBA? I have images where the values (0-255) in the raw pixels have an actual data meaning. Depending on the time of year, the actual index palette changes, (so the displayed colors change) but not the 0-255 values in each pixel. I can do this client side, but with overhead which I don&#8217;t want. </p>
<p>What I want to do is a browser side calculation. So when a user mouses over an image, the x,y provides the pixel needed, and the 0-255 is extracted. This is then converted to a data value (using a know formula,) which can be displayed for the user (and of course, a coresponding lat long which can be determined since I know the outer lat/long bounds of the image)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: beej</title>
		<link>http://beej.us/blog/2010/02/html5s-canvas-part-ii-pixel-manipulation/comment-page-1/#comment-8168</link>
		<dc:creator>beej</dc:creator>
		<pubDate>Fri, 14 Oct 2011 16:42:17 +0000</pubDate>
		<guid isPermaLink="false">http://beej.us/blog/?p=581#comment-8168</guid>
		<description>&lt;a href=&quot;#comment-8136&quot; rel=&quot;nofollow&quot;&gt;@michael &lt;/a&gt; This is tricky for a couple reasons.  (If it&#039;s possible, given your needs, to read the pixel at x,y before the transform, it could be a lot better.)

First of all, the math isn&#039;t hard, and there are a number of JS libraries to do it.  (I&#039;ve used Sylvester: http://sylvester.jcoglan.com/ ).  Basically, you have to run the math again in parallel to get the result.

However, canvas will render to a subpixel.  This means that part of your color could be on one pixel, and the rest would be on another.  It might be a while pixel, originally, but it might turn to several gray pixels after rotation.</description>
		<content:encoded><![CDATA[<p><a href="#comment-8136" rel="nofollow">@michael </a> This is tricky for a couple reasons.  (If it&#8217;s possible, given your needs, to read the pixel at x,y before the transform, it could be a lot better.)</p>
<p>First of all, the math isn&#8217;t hard, and there are a number of JS libraries to do it.  (I&#8217;ve used Sylvester: <a href="http://sylvester.jcoglan.com/" rel="nofollow">http://sylvester.jcoglan.com/</a> ).  Basically, you have to run the math again in parallel to get the result.</p>
<p>However, canvas will render to a subpixel.  This means that part of your color could be on one pixel, and the rest would be on another.  It might be a while pixel, originally, but it might turn to several gray pixels after rotation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: beej</title>
		<link>http://beej.us/blog/2010/02/html5s-canvas-part-ii-pixel-manipulation/comment-page-1/#comment-8167</link>
		<dc:creator>beej</dc:creator>
		<pubDate>Fri, 14 Oct 2011 16:35:26 +0000</pubDate>
		<guid isPermaLink="false">http://beej.us/blog/?p=581#comment-8167</guid>
		<description>&lt;a href=&quot;#comment-8081&quot; rel=&quot;nofollow&quot;&gt;@OrNot &lt;/a&gt; getImageData() and putImageData() operate on a low level, referring to the pixels in the bitmap backing store, and are not affected by the drawing context.

In the spec: &quot;The current path, transformation matrix, shadow attributes, global alpha, the clipping region, and global composition operator must not affect the getImageData() and putImageData() methods.&quot;</description>
		<content:encoded><![CDATA[<p><a href="#comment-8081" rel="nofollow">@OrNot </a> getImageData() and putImageData() operate on a low level, referring to the pixels in the bitmap backing store, and are not affected by the drawing context.</p>
<p>In the spec: &#8220;The current path, transformation matrix, shadow attributes, global alpha, the clipping region, and global composition operator must not affect the getImageData() and putImageData() methods.&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: michael</title>
		<link>http://beej.us/blog/2010/02/html5s-canvas-part-ii-pixel-manipulation/comment-page-1/#comment-8136</link>
		<dc:creator>michael</dc:creator>
		<pubDate>Thu, 01 Sep 2011 04:35:03 +0000</pubDate>
		<guid isPermaLink="false">http://beej.us/blog/?p=581#comment-8136</guid>
		<description>I too have the same question as OrNot, although what I want to do is to read the pixel at (x,y) after a translate and rotation.  Is this possible?  perhaps there is a way to get the &quot;real&quot; coordinates of x and y after a translate and rotate has been done, and get the pixel at the &quot;real&quot; coordinates?</description>
		<content:encoded><![CDATA[<p>I too have the same question as OrNot, although what I want to do is to read the pixel at (x,y) after a translate and rotation.  Is this possible?  perhaps there is a way to get the &#8220;real&#8221; coordinates of x and y after a translate and rotate has been done, and get the pixel at the &#8220;real&#8221; coordinates?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: OrNot</title>
		<link>http://beej.us/blog/2010/02/html5s-canvas-part-ii-pixel-manipulation/comment-page-1/#comment-8081</link>
		<dc:creator>OrNot</dc:creator>
		<pubDate>Sun, 17 Jul 2011 12:17:57 +0000</pubDate>
		<guid isPermaLink="false">http://beej.us/blog/?p=581#comment-8081</guid>
		<description>Nice article. 

I have a question:

 I modify your code as below:
  
   
    c.translate(50,50);
    
// put pixel data on canvas
    c.putImageData(imageData, 0, 0);


Why is the output image still in (0,0)  not (50,50)?</description>
		<content:encoded><![CDATA[<p>Nice article. </p>
<p>I have a question:</p>
<p> I modify your code as below:</p>
<p>    c.translate(50,50);</p>
<p>// put pixel data on canvas<br />
    c.putImageData(imageData, 0, 0);</p>
<p>Why is the output image still in (0,0)  not (50,50)?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Micah Smith</title>
		<link>http://beej.us/blog/2010/02/html5s-canvas-part-ii-pixel-manipulation/comment-page-1/#comment-7591</link>
		<dc:creator>Micah Smith</dc:creator>
		<pubDate>Thu, 10 Feb 2011 15:03:54 +0000</pubDate>
		<guid isPermaLink="false">http://beej.us/blog/?p=581#comment-7591</guid>
		<description>Great article, and great writing style.</description>
		<content:encoded><![CDATA[<p>Great article, and great writing style.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: beej</title>
		<link>http://beej.us/blog/2010/02/html5s-canvas-part-ii-pixel-manipulation/comment-page-1/#comment-4828</link>
		<dc:creator>beej</dc:creator>
		<pubDate>Sat, 17 Jul 2010 04:16:47 +0000</pubDate>
		<guid isPermaLink="false">http://beej.us/blog/?p=581#comment-4828</guid>
		<description>&lt;a href=&quot;#comment-4814&quot; rel=&quot;nofollow&quot;&gt;@Vidar &lt;/a&gt; If you&#039;re going HTML5, you also have the option to rotate individual DOM elements (like images) in CSS3 with the &quot;transform&quot; property.  (But of course, using canvas is an option, as well.)

As for collision detection, check out this fantastic page at Gamasutra:

http://www.gamasutra.com/view/feature/3383/simple_intersection_tests_for_games.php

Page 5 talks about &quot;Oriented Bounded Boxes&quot; which might be along the lines of what you need.</description>
		<content:encoded><![CDATA[<p><a href="#comment-4814" rel="nofollow">@Vidar </a> If you&#8217;re going HTML5, you also have the option to rotate individual DOM elements (like images) in CSS3 with the &#8220;transform&#8221; property.  (But of course, using canvas is an option, as well.)</p>
<p>As for collision detection, check out this fantastic page at Gamasutra:</p>
<p><a href="http://www.gamasutra.com/view/feature/3383/simple_intersection_tests_for_games.php" rel="nofollow">http://www.gamasutra.com/view/feature/3383/simple_intersection_tests_for_games.php</a></p>
<p>Page 5 talks about &#8220;Oriented Bounded Boxes&#8221; which might be along the lines of what you need.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vidar</title>
		<link>http://beej.us/blog/2010/02/html5s-canvas-part-ii-pixel-manipulation/comment-page-1/#comment-4814</link>
		<dc:creator>Vidar</dc:creator>
		<pubDate>Sat, 17 Jul 2010 00:36:34 +0000</pubDate>
		<guid isPermaLink="false">http://beej.us/blog/?p=581#comment-4814</guid>
		<description>I&#039;m making a javascript/html5/php/mysql online 2d strategy game. It will be posted at cyberempire.net. &lt;a href=&quot;http://cyberempire.net&quot; rel=&quot;nofollow&quot;&gt;game site&lt;/a&gt; Don&#039;t mind the java stuff there, it was the plan to make it in java, but I thought I would try with javascript. My problem before was finding an easy way to rotate images, problem solved with canvas. But, I would appreciate it if anybody had a fast  collision detection routine.</description>
		<content:encoded><![CDATA[<p>I&#8217;m making a javascript/html5/php/mysql online 2d strategy game. It will be posted at cyberempire.net. <a href="http://cyberempire.net" rel="nofollow">game site</a> Don&#8217;t mind the java stuff there, it was the plan to make it in java, but I thought I would try with javascript. My problem before was finding an easy way to rotate images, problem solved with canvas. But, I would appreciate it if anybody had a fast  collision detection routine.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

