1

I'm trying to draw on an image using CGContextRef with the following piece of code:

UIGraphicsBeginImageContextWithOptions(size, false, 0);
CGContextRef context = UIGraphicsGetCurrentContext();
// After getting the context i pass it to a C++ backend by an appropriate wrapper and do some drawing operations.

Then I try to get the image from context with the following piece of code:

CGImageRef image = [UIGraphicsGetImageFromCurrentImageContext() CGImage];

But this returns an image with size (0,0).

I tried to get the image with:

CGImageRef image = CGBitmapContextCreateImage(context);

This returns a blank image with the original size multiplied by 3 for both width and height.

Any suggestions?

Mo Abdul-Hameed
  • 6,030
  • 2
  • 23
  • 36
  • If the image is being drawn in the `context`, then `UIGraphicsGetImageFromCurrentImageContext()` should do the trick. There may be some problem with C++ backend. – KrishnaCA Nov 14 '16 at 09:22
  • @KrishnaChaitanyaAmjuri Thank you for your response, but I have my C++ backend connected to another frontend and it works as expected. – Mo Abdul-Hameed Nov 14 '16 at 09:32

0 Answers0