<?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>eManagr News &#187; Technical</title>
	<atom:link href="http://blog.emanagr.com/tag/technical/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.emanagr.com</link>
	<description>Happenings with the premiere automated project manager</description>
	<lastBuildDate>Sat, 03 Jul 2010 14:32:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>How Big Is That Flash? [2]</title>
		<link>http://blog.emanagr.com/2009/03/23/how-big-is-that-flash/</link>
		<comments>http://blog.emanagr.com/2009/03/23/how-big-is-that-flash/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 17:00:32 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://blog.emanagr.com/2009/03/23/how-big-is-that-flash/</guid>
		<description><![CDATA[We interrupt this blog with a quick technical discussion. As people start using eManagr, we obviously worry that features seeming obvious in design are, in fact, weird and confusing. So, in the walkthrough, we&#8217;ll soon add Flash video for each step. Problem: I have a special hatred of arbitrary numbers in markup, and if you [...]]]></description>
			<content:encoded><![CDATA[<p>We interrupt this blog with a quick technical discussion.</p>
<p>As people start using eManagr, we obviously worry that features seeming obvious in design are, in fact, weird and confusing.  So, in the walkthrough, we&#8217;ll soon add Flash video for each step.</p>
<p>Problem:  I have a special hatred of arbitrary numbers in markup, and if you don&#8217;t tell your browser about the video, it&#8230;apparently picks a height and width out of a hat.  Fun, eh?<br />
<span id="more-7"></span></p>
<p>Searching Google supplied a lot of advice that boiled down to &#8220;just put in the numbers.&#8221;</p>
<p>Thankfully, it turns out that the SWF format is relatively well-documented.  Unfortunately, it&#8217;s the sort of bit-twiddling format that was uncool back when MS-DOS roamed the Earth.  In hopes of saving somebody else the trouble of finding the video&#8217;s size, here&#8217;s the Ruby code we&#8217;re using.  It&#8217;s pretty straightforward, so it wouldn&#8217;t be hard to hack as C, PHP, or whatever else you need.</p>
<pre>
def flashsize(filename)

  flash = File.open(filename)

  bytes = flash.read[8,65]          # The length is semi-arbitrary

  flash.close  size = bytes[0] &gt;&gt; 3 # Yes, the number of bits per coordinate is stored in five bits

  rect = bytes[0..size/2]

  rect.reverse!

  carry = 0

  0.upto(rect.length - 1) do |i|    # Worse:  The coordinates aren't byte-aligned!

    k = rect[i] &gt;&gt; 3

    rect[i] = (rect[i] &lt;&lt; 5) | carry

    carry = k

  end

  rect.reverse!

size = size / 8                     # Turn the byte-aligned numbers into the size

  xmin = intfrombytes(rect,size*0,size)

  xmax = intfrombytes(rect,size*1,size)

  ymin = intfrombytes(rect,size*2,size)

  ymax = intfrombytes(rect,size*3,size)

  width = xmax - xmin

  height = ymax - ymin

return width, height

end

def intfrombytes(str, offset, length)

  result = 0

  0.upto(length - 1) do |i|

    result = ( result &lt;&lt; 8 ) | str[offset + i]

  end

  return result

end</pre>
<p>Ta-da!</p>
<p>Yes, I left out the error checks and ignored cases where coordinates are stored in fractional bytes.  Mostly because I&#8217;d rather correct those errors by beating up the people who cause the error.  But as long as nobody&#8217;s that stupid, this finds you the height and width.  You can then push that into your video&#8217;s HTML tag and everybody will be happy.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.emanagr.com/2009/03/23/how-big-is-that-flash/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
