미리 감사드립니다. 이미지 뷰를 오버레이 뷰로 카메라에 추가하고 (카메라 뷰 및 이미지 뷰)를 단일 이미지로 저장하려고합니다. 나는 그것을 검색하고 stackoverflow 주어진 예제를 시도했지만 아무것도 빈 화면보다 표시되지 않습니다. 아무도 나를 도와주세요.카메라보기에 오버레이보기를 추가하고 저장하는 방법
0
A
답변
1
- (void)renderView:(UIView*)view inContext:(CGContextRef)context
{
// -renderInContext: renders in the coordinate space of the layer,
// so we must first apply the layer's geometry to the graphics context
CGContextSaveGState(context);
// Center the context around the window's anchor point
CGContextTranslateCTM(context, [view center].x, [view center].y);
// Apply the window's transform about the anchor point
CGContextConcatCTM(context, [view transform]);
// Offset by the portion of the bounds left of and above the anchor point
CGContextTranslateCTM(context,
-[view bounds].size.width * [[view layer] anchorPoint].x,
-[view bounds].size.height * [[view layer] anchorPoint].y);
// Render the layer hierarchy to the current context
[[view layer] renderInContext:context];
// Restore the context
CGContextRestoreGState(context);
}
// this get called when an image has been taken from the camera
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info valueForKey:UIImagePickerControllerOriginalImage];
//cameraImage = image;
CGSize imageSize = [[UIScreen mainScreen] bounds].size;
if (NULL != UIGraphicsBeginImageContextWithOptions)
UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0);
else
UIGraphicsBeginImageContext(imageSize);
CGContextRef context = UIGraphicsGetCurrentContext();
// Draw the image returned by the camera sample buffer into the context.
// Draw it into the same sized rectangle as the view that is displayed on the screen.
float menubarUIOffset = 44.0;
UIGraphicsPushContext(context);
[image drawInRect:CGRectMake(0, 0, imageSize.width, imageSize.height-menubarUIOffset)];
UIGraphicsPopContext();
// Render the camera overlay view into the graphic context that we created above.
[self renderView:self.imagePicker.view inContext:context];
// Retrieve the screenshot image containing both the camera content and the overlay view
UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();
UIImageWriteToSavedPhotosAlbum(screenshot, nil, nil, nil);
UIGraphicsEndImageContext();
[self.imagePicker dismissModalViewControllerAnimated:YES];
}
희망이 유를 받았습니다 감사 내가 그것을 시도 할 것이다
+0
도움이 대답에 해당하는 눈금을 클릭하여 몇 가지 답변을 받아 들일 수 있습니다 ur 응답을 위해. –
+0
UIImagePickerController를 사용해 볼 수 있습니다. 그것은 훨씬 쉬울 것입니다 – visakh7
+0
예. 나는 그것을 사용하고 있습니다. –
관련 문제
- 1. 회전하는 UIWindow에 오버레이보기를 추가하는 방법
- 2. 지도에 오버레이보기를 추가하는 방법은 무엇입니까?
- 3. Android에서 증강 현실을 사용하여 카메라보기에 표시된 객체의 위치를 식별하는 방법
- 4. iPhone의 카메라보기에 이미지를 오버레이하는 방법은 무엇입니까?
- 5. iPhone SDK에서 오버레이보기를 만들 수있는 방법이 있습니까?
- 6. iPhone 개발 - 투명한 오버레이보기를 구현하려면 어떻게해야합니까?
- 7. NSUserDefaults에 NSMutableArray를 저장하는 방법
- 8. 저장하는 방법 안드로이드에서 WebView를 저장하는 방법
- 9. 보석 의존성을 추가하고 번들을 설치하는 방법
- 10. jar에서 리소스 파일을 추가하고 읽는 방법
- 11. DataGridview에 행을 추가하고 데이터를 삽입하는 방법 C#
- 12. div 클릭 이벤트에서 Jquery를 추가하고 제거하는 방법
- 13. Drupal : 양식을 추가하고 기능을 수행하는 방법
- 14. UIButton 클릭시 UITextfield를 추가하고 편집 가능하게하는 방법
- 15. 장바구니에 맞춤 입력란을 추가하고 순서대로 전송하는 방법
- 16. 버튼을 추가하고 ASP.net에서 클릭하여 연결하는 방법
- 17. SQL 권한을 사용하여 데이터를 추가하고 확인하는 방법?
- 18. 선택 드롭 다운을 추가하고 자동으로 채우는 방법
- 19. % 기호를 추가하고 색을 지정하십시오.
- 20. 데이터베이스에 질문을 저장하는 방법
- 21. RatingBar 등급을 저장하는 방법?
- 22. 이미지에 UIImageViewController를 저장하는 방법
- 23. 옵션을 저장하는 방법?
- 24. NSTreeController 파일에 저장하는 방법
- 25. CMS 콘텐츠를 저장하는 방법
- 26. Webservice에서 XML을 저장하는 방법
- 27. Markdown 주석을 저장하는 방법
- 28. NSMutableArray에 CGGradientRef를 저장하는 방법
- 29. 데이터베이스에 이미지를 저장하는 방법
- 30. 거래에서 저장하는 방법?
그냥 지금 개까지 카메라 옵션을 사용하지 않은 7kv7 @ 당신에게 – visakh7