title: Objective-C wrapper class for CGContext?
body: <p>Has anyone created a wrapper class for the CGContext group of functions?</p>
  
  <p>I created a simple Gradient class yesterday which encapsulates a subset of CGGradient functionality for simpler memory management.  It was pretty straightforward.  But there are obviously quite a few more CGContext operations, and I'm not sure I'd want to reinvent the wheel there.</p>
  
  <p>Essentially what I'm looking for is stuff like...</p>
  
  <pre><code>@interface CGContext : NSObject
  {
      CGContextRef context;
  }
  
  + (CGContext *) bitmapContextWithData:(void *)data
                                  width:(size_t)width
                                 height:(size_t)height
                       bitsPerComponent:(size_t)bitsPerComponent
                            bytesPerRow:(size_t)bytesPerRow
                             colorspace:(CGColorSpaceRef)colorspace
                             bitmapInfo:(CGBitmapInfo)bitmapInfo;
  
  - (void) saveGState;
  - (void) restoreGState;
  
  - (void) setBlendMode:(CGBlendMode)mode;
  
  - (void) addLineToPoint:(CGPoint)point;
  - (void) addLineToPointX:(CGFloat)x pointY:(CGFloat)y;
  
  - (void) drawImage:(CGImageRef)image rect:(CGRect)rect;
  
  - (void) concatCTM:(CGAffineTransform)transform;
  - (CGAffineTransform) getCTM;
  
  @end
  </code></pre>
  
  <p>and so forth.</p>
  
  <p>(I do 99% of my drawing into off-screen bitmaps, which is why I care about memory management in this case.  If I was always drawing into the current UI graphics context such as the active screen, then I wouldn't really find a wrapper class to be of much use.)</p>