2013-07-22 3 views
-1

날짜와 시간으로 사진을 디지털 사진처럼 사진에 표시되도록 찍은 상태에서 사진을 찍어야합니다.iOS의 디지털 카메라와 같은 날짜의 카메라에서 사진 찍기

+0

날짜와 시간을 이미지 파일의 일부로 유지 하시겠습니까 (영구적으로 표시 하시겠습니까? 아니면 이미지 맨 위에 표시되도록 하시겠습니까? – joshuahealy

+0

이미지 파일의 일부가 영구적 인 –

+0

으로 표시되지만 텍스트는 표시되지 않습니다. –

답변

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