-
Notifications
You must be signed in to change notification settings - Fork 271
snapshoted
Franken Zeng edited this page Oct 9, 2017
·
5 revisions
主播可以在预览时打开美颜截图,作为自己的房间的图片
在SDK中有如下三种方式可以得到截图, 可以根据需要选择
takePhotoWithQuality参数配置: jpegCompressionQuality:设置图像的压缩比例 filename:图片的文件名
-(void) takePhotoWithQuality:(CGFloat)jpegCompressionQuality
fileName:(NSString *)filename;
[_kit.streamerBase takePhotoWithQuality:1 fileName:@"3/4/c.jpg"];
getSnapshotWithCompletion获取当前编码/预览的截图,通过完成代码块获取到截图完成的图像
- (void)saveImage: (UIImage *)image
to: (NSString*)path {
NSString * dir = [NSHomeDirectory() stringByAppendingString:@"/Documents/"];
NSString * file = [dir stringByAppendingPathComponent:path];
NSData *imageData = UIImagePNGRepresentation(image);
BOOL ret = [imageData writeToFile:file atomically:YES];
NSLog(@"write %@ %@", file, ret ? @"OK":@"failed");
}
[_kit.streamerBase getSnapshotWithCompletion:^(UIImage * img){
[weakself saveImage: img
to: @"snap1.png" ];
}];
(saveImage 参照上一种方式) 需要先声明下一帧图像需要作为截图, 然后使用滤镜的imageFromCurrentFramebuffer属性可以得到UIImage*类型的图像
[_filter useNextFrameForImageCapture];
[self saveImage: _filter.imageFromCurrentFramebuffer
to: @"snap2.png" ];