title: 9-slice scaling/stretching in the background, using Cocoa on iOS
body: <p>I want to stretch an image using &quot;9-slice&quot; scaling, where only the centre of the image is scaled. Exactly like UIImage's<a href="http://developer.apple.com/library/ios/#documentation/uikit/reference/UIImage_Class/Reference/Reference.html#//apple_ref/occ/instm/UIImage/stretchableImageWithLeftCapWidth:topCapHeight:" rel="noreferrer"><code>stretchableImageWithLeftCapWidth</code></a> method, however I want to do this in a background thread. I understand that this method can only be used in the gui thread.</p>
  <p>I'm developing on iOS / iPad / iPhone.</p>
  <p>Does anyone have a code snippet, or know of a library that can do this? I'm trying to not re-invent the wheel!</p>
  <h3>Some related references I've found useful:</h3>
  <p>CGContext docs:</p>
  <ul>
  <li><a href="http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/CGContext/Reference/reference.html" rel="noreferrer">http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/CGContext/Reference/reference.html</a></li>
  </ul>
  <p>Nice blog entry on drawing in the background:</p>
  <ul>
  <li><a href="http://joris.kluivers.nl/iphone-dev/?p=BackgroundImageProcessing" rel="noreferrer">http://joris.kluivers.nl/iphone-dev/?p=BackgroundImageProcessing</a></li>
  </ul>
  <p>Rotating an image using CGContext:</p>
  <ul>
  <li><a href="http://blog.coriolis.ch/2009/09/04/arbitrary-rotation-of-a-cgimage/" rel="noreferrer">http://blog.coriolis.ch/2009/09/04/arbitrary-rotation-of-a-cgimage/</a></li>
  </ul>