Need to take photo from the application with date and time the photo has been taken to be displayed in photo just like digital camera.
Asked
Active
Viewed 92 times
-1

icodebuster
- 8,890
- 7
- 62
- 65

Muruganandan Pandi
- 73
- 1
- 1
- 7
-
Do you want the date and time to be part of the image file (i.e. permanent) or just displayed over the top of the image when you view it? – joshuahealy Jul 22 '13 at 03:54
-
ya part of image file as permanent – Muruganandan Pandi Jul 22 '13 at 04:04
-
but text is not displayed – Muruganandan Pandi Jul 22 '13 at 04:06
1 Answers
0
-(UIImage *)addText:(UIImage *)img text:(NSString *)text1;
{
int w = img.size.width;
int h = img.size.height;
//lon = h - lon;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(NULL, w, h, 8, 4 * w, colorSpace, kCGImageAlphaPremultipliedFirst);
CGContextDrawImage(context, CGRectMake(0, 0, w, h), img.CGImage);
CGContextSetRGBFillColor(context, 0.0, 0.0, 1.0, 1);
char* text = (char *)[text1 cStringUsingEncoding:NSASCIIStringEncoding];// "05/05/09";
CGContextSelectFont(context, "Arial", 18, kCGEncodingMacRoman);
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);
return [UIImage imageWithCGImage:imageMasked];
}

karthika
- 4,085
- 3
- 21
- 23

Muruganandan Pandi
- 73
- 1
- 1
- 7