0

Is it not wasteful that there is a requirement that if you want to draw into a UIImage, that it always has to be into a new UIImage created with UIGraphicsBeginImageContext?

If frequent drawing needs to happen, why not let us draw into a preexisting UIImage?

Or is there a way to do this already?

2 Answers2

0

This is because UIImage is not mutable. If you are constantly rendering to a new CGBitmapContext, then you are doing something wrong in your application.

Richard J. Ross III
  • 55,009
  • 24
  • 135
  • 201
0

Nope there is not, but you could have a context that you keep updating it before you realize it to an image, that is one way to not begin a context and end it, keep it open for further drawings

Omar Abdelhafith
  • 21,163
  • 5
  • 52
  • 56
  • Use the following #import CGContextRef bitmapContext = CGBitmapContextCreate(nil, imageSize.width, imageSize.height, 8, imageSize.width * 4, CGColorSpaceCreateDeviceRGB(), kCGImageAlphaNoneSkipFirst) – Omar Abdelhafith Jun 04 '12 at 15:27
  • Yes you could draw a context in the UIView -drawrect function – Omar Abdelhafith Jun 04 '12 at 15:40
  • use CGImageRef only if you want to realize it to an uiimage (png, jpg, etc...) check the following http://stackoverflow.com/questions/3550201/how-exactly-to-make-a-cgimageref-from-an-image-on-disk – Omar Abdelhafith Jun 04 '12 at 15:54