<?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>Codec &#187; context</title>
	<atom:link href="http://www.trembl.org/codec/tag/context/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.trembl.org/codec</link>
	<description>A Personal Polylogic Code/Decode &#039;Zettelkasten&#039;</description>
	<lastBuildDate>Thu, 02 Feb 2012 03:38:01 +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>Combining Images with UIImage &amp; CGContext &#8211; (Offscreen drawing)</title>
		<link>http://www.trembl.org/codec/334/</link>
		<comments>http://www.trembl.org/codec/334/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 09:25:49 +0000</pubDate>
		<dc:creator>Georg Tremmel</dc:creator>
				<category><![CDATA[Raw]]></category>
		<category><![CDATA[add]]></category>
		<category><![CDATA[combine]]></category>
		<category><![CDATA[context]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[layer]]></category>
		<category><![CDATA[lockFocus]]></category>
		<category><![CDATA[NSImage]]></category>
		<category><![CDATA[offscreen]]></category>
		<category><![CDATA[Quartz]]></category>
		<category><![CDATA[UIImage]]></category>

		<guid isPermaLink="false">http://www.trembl.org/codec/?p=334</guid>
		<description><![CDATA[In Cocoa NSImage has a lockFocus method, that allows to draw images offscreen and combine them into one. &#91;img lockFocus&#93;; //... &#91;img unlockFocus&#93;; On the iPhone, UIImage lacks the lockFocus methods, instead the following: // Create new offscreen context with desired size UIGraphicsBeginImageContext&#40;CGSizeMake&#40;64.0f, 64.0f&#41;&#41;; &#160; // draw img at 0,0 in the context &#91;img drawAtPoint:CGPointZero&#93;; [...]]]></description>
			<content:encoded><![CDATA[<p>In Cocoa NSImage has a lockFocus method, that allows to draw images offscreen and combine them into one.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">&#91;</span>img lockFocus<span style="color: #002200;">&#93;</span>;
<span style="color: #11740a; font-style: italic;">//...</span>
<span style="color: #002200;">&#91;</span>img unlockFocus<span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>On the iPhone, UIImage lacks the lockFocus methods, instead the following:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">// Create new offscreen context with desired size</span>
UIGraphicsBeginImageContext<span style="color: #002200;">&#40;</span>CGSizeMake<span style="color: #002200;">&#40;</span>64.0f, 64.0f<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>;
&nbsp;
<span style="color: #11740a; font-style: italic;">// draw img at 0,0 in the context</span>
<span style="color: #002200;">&#91;</span>img drawAtPoint<span style="color: #002200;">:</span>CGPointZero<span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #11740a; font-style: italic;">// draw another at 0,0 in the context, maybe with an alpha value</span>
<span style="color: #002200;">&#91;</span>another drawAtPoint<span style="color: #002200;">:</span>CGPointZero<span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #11740a; font-style: italic;">// ... and other operations</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">// assign context to UIImage</span>
UIImage <span style="color: #002200;">*</span>outputImg <span style="color: #002200;">=</span> UIGraphicsGetImageFromCurrentImageContext<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;
&nbsp;
<span style="color: #11740a; font-style: italic;">// end context</span>
UIGraphicsEndImageContext<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.trembl.org/codec/334/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

