【问题标题】:Screenshot does not show the image in video屏幕截图不显示视频中的图像
【发布时间】:2015-05-11 06:15:20
【问题描述】:

我需要通过单击按钮获取视频的屏幕截图。下面是用于此的代码,但图像仅显示视频的底部部分,即随着时间的推移播放和进度..I已使用 MPMoviePlayerController 播放视频。

CGRect rect = [_moviePlayer.view bounds];
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[_moviePlayer.view.layer renderInContext:context];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

UIImageView   *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 100, 100, 100)];
[imgView setImage:image];
imgView.layer.borderWidth = 2.0;
[_firstimage addSubview:imgView];

NSURL *url=[NSURL URLWithString:@"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"];

这就是它的显示方式..我怎样才能获得视频图像?谁能帮帮我..

【问题讨论】:

标签: objective-c iphone


【解决方案1】:
【解决方案2】:
CGImageRef originalImage = UIGetScreenImage();
CGImageRef videoImage = CGImageCreateWithImageInRect(originalImage,   CGRectMake(0, 0, 680, 300));
UIImage *snapShotImage = [UIImage imageWithCGImage:videoImage];
UIImageWriteToSavedPhotosAlbum(snapShotImage, nil, nil, nil);
CGImageRelease(originalImage);
CGImageRelease(videoImage);
UIImageView   *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 100, 250, 200)];
[imgView setImage:snapShotImage];
imgView.layer.borderWidth = 2.0;
[_firstimage addSubview:imgView];

此代码有效...感谢您的帮助...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-30
    • 1970-01-01
    • 1970-01-01
    • 2011-11-26
    • 2018-01-02
    • 1970-01-01
    相关资源
    最近更新 更多