3

I have a CGBitmapContext (bitmapContext) and I would like to draw some rectangle part (rect) of it to the current CGContext (context).

Right now I do that way:

CGContextRef context = UIGraphicsGetCurrentContext();
CGImageRef cgImage = CGBitmapContextCreateImage(bitmapContext);
CGContextClipToRect(context, rect);
CGContextDrawImage(context, CGRectMake(0, 0, width, height), cgImage);
CGImageRelease(cgImage);

Is it optimal? What is the best way to do it?

alexey
  • 8,360
  • 14
  • 70
  • 102

1 Answers1

2

The alternative seems to be to create a sub-image, which I can only imagine to be less optimal.

Chris Becke
  • 34,244
  • 12
  • 79
  • 148