views:

32

answers:

1

Hi,

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.

A: 

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
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
Cirrostratus
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