2

i need to take a snapshot of my current ipad-view. That view loads and plays a video. I found this function which works almost really well.

- (UIImage*)captureView:(UIView *)view {
    CGRect rect =  [[UIScreen mainScreen] bounds];   
    UIGraphicsBeginImageContext(rect.size);  
    CGContextRef context = UIGraphicsGetCurrentContext();    
    [view.layer renderInContext:context];    
    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();  
    UIGraphicsEndImageContext();     
    return img;
}

(Source from: LINK)

The problem is, that the current frame of the playing video is not captured, only the view but without video-content. Do i forgot to update the display or anything else before saving the image? Is there a special function that reads the latest screen-values?

Thanks for your time and help.

geforce
  • 2,593
  • 3
  • 28
  • 44
  • See the answer in this question: http://stackoverflow.com/questions/3129352/need-to-capture-uiview-into-a-uiimage-including-all-subviews – Logachu Sep 30 '11 at 04:27

1 Answers1

0

Have you tried using the UIGetScreenImage() function?

It's private, but Apple allows to use it, so your app will be validated for the App Store, even if you use it.

You just need to declare its prototype, so the compiler won't complain:

CGImageRef UIGetScreenImage( void );

Note: you can create a NSImage from the CGImageRef with the following NSImage method:

- ( id )initWithCGImage: ( CGImageRef )cgImage size:( NSSize )size;
Macmade
  • 52,708
  • 13
  • 106
  • 123
  • Several developers' apps have been rejected for using that function. Some people get caught, others do not. See: http://stackoverflow.com/questions/1531815/takepicture-vs-uigetscreenimage – james_womack Jul 10 '10 at 22:38
  • If i am not wrong the 3.2+ SDK has the MPMoviePlayerController which provides a public method to get the snap of the Video at any give instance. If u are looking for ScreenShot With complete view then please ignore this. – RVN Aug 19 '10 at 11:24