gpt4 book ai didi

ios - 从 MPMoviePlayerController 调整缩略图大小

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:36:11 24 4
gpt4 key购买 nike

我正在尝试使用 MPMoviePlayerController 调整使用 UIImagePickerController 捕获的视频缩略图的大小。这是我正在使用的:

         self.moviePlayer.contentURL = [info objectForKey:UIImagePickerControllerMediaURL];
UIImage *thumbnail = [self.moviePlayer thumbnailImageAtTime:1 timeOption:MPMovieTimeOptionNearestKeyFrame];
self.thumbnailImage = [self resizeImage:thumbnail toWidth:75.0 andHeight:75.0];

这是我调整大小的方法:

- (UIImage *)resizeImage:(UIImage *)image toWidth:(float)width andHeight:(float)height {

CGSize newSize = CGSizeMake(width, height);

CGRect newRect = CGRectMake(0, 0, width, height);

UIGraphicsBeginImageContext(newSize);
[self.image drawInRect:newRect];
UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

return resizedImage;

}

resize 方法适用于在 imagePicker 中捕获的照片,但由于某种原因,当我在视频缩略图上使用它时图像是空白的。如果我不调整它的大小,它看起来很好,但由于某种原因,调整它的大小会把它弄乱。我正在使用 ios7 并在 iPhone 5s 上进行测试

最佳答案

UIGraphicsBeginImageContext(newSize);
[image drawInRect:newRect];
UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

我在使用 [self.image drawInRect] 而不是 [image drawInRect] 愚蠢的错误。哇。

关于ios - 从 MPMoviePlayerController 调整缩略图大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22031824/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com