In my iPhone app, I am capturing the screen shot of the device. In the screen shot view I have different views with layer hierarchy as, at the bottom a blank background view, then over the background a image view, and over the image view a EAGLView. I want to capture the screen shot of the device with the frame size of the EAGLView and it should include the imageview and background view. Here is my code:
- (IBAction)captureScreen:(id)sender{
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.cameraAppView.layer renderInContext:UIGraphicsGetCurrentContext()]; // cameraAppView is the EAGLView
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
CGImageRef imageRef = CGImageCreateWithImageInRect([viewImage CGImage], cameraAppView.frame);
UIImage *img = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
}
But now I am only getting the screen shot of EAGLView, I want to get screen shot of the device through the EAGLView frame size. How can I do that?
Edit
Sorry, I missed a point in my question. There are also some other subviews in the same screen. But all of them are top of the EAGLView. I want to capture the image of the views, below the EAGLView including the EAGLView content.