在iOS中使用数码相机拍摄相机中的照片

问题描述:

需要从应用程序中拍摄日期和时间的照片,照片与数码相机一样被显示在照片中。在iOS中使用数码相机拍摄相机中的照片

+0

想要将日期和时间作为图像文件的一部分(即永久性),或只是在查看图像时在图像顶部显示? – joshuahealy

+0

ya图像文件的一部分为永久 –

+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]; 
}