-
-
Save jgv/2925542 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage]; | |
//imageView.image = image; | |
int w = image.size.height; | |
int h = image.size.width; | |
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); | |
CGContextRef context = CGBitmapContextCreate(NULL, w, h, 8, 4 * w, colorSpace, kCGImageAlphaPremultipliedFirst); | |
CGContextDrawImage(context, CGRectMake(0, 0, w, h), image.CGImage); | |
CGContextSetRGBFillColor(context, 0.0, 0.0, 1.0, 1); | |
NSString *text1 = @"YOLO"; | |
//UIImage *newImage = addText(image, @"YOLO"); | |
char* text = (char *)[text1 cStringUsingEncoding:NSASCIIStringEncoding];// "05/05/09"; | |
CGContextSetTextDrawingMode(context, kCGTextFill); | |
CGContextSetRGBFillColor(context, 255, 255, 255, 1); | |
//rotate text | |
CGContextSetTextMatrix(context, CGAffineTransformMakeRotation( -M_PI/4 )); | |
CGContextShowTextAtPoint(context, 4, 52, text, strlen(text)); | |
CGImageRef imageMasked = CGBitmapContextCreateImage(context); | |
CGContextRelease(context); | |
CGColorSpaceRelease(colorSpace); | |
UIImage *newImage = [UIImage imageWithCGImage:imageMasked]; | |
imageView.image = newImage; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment