/ Published in: Objective C
URL: http://www.codza.com/creating-and-drawing-on-a-new-uiimage
input: width, height and inputImage output: outputImage
Expand |
Embed | Plain Text
CGFloat width, height; // max 1024 due to Core Graphics limitations UIImage *inputImage; // input image to be composited over new image as example // create a new bitmap image context // UIGraphicsBeginImageContext(CGSizeMake(width, height)); // get context // CGContextRef context = UIGraphicsGetCurrentContext(); // push context to make it current // (need to do this manually because we are not drawing in a UIView) // UIGraphicsPushContext(context); // // [drawing code comes here- look at CGContext reference // for available operations] // // this example draws the inputImage into the context // [inputImage drawInRect:CGRectMake(0, 0, width, height)]; // pop context // UIGraphicsPopContext(); // get a UIImage from the image context- enjoy!!! // UIImage *outputImage = UIGraphicsGetImageFromCurrentImageContext(); // clean up drawing environment // UIGraphicsEndImageContext();
You need to login to post a comment.
