我试图调整一个缩略图从一个使用UIImagePickerController使用MPMoviePlayerController拍摄的视频中的大小。下面是我使用的内容:
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;
}调整大小的方法适用于在imagePicker中捕获的照片,但由于某种原因,当我在视频缩略图上使用它时,图像是空白的。如果我不调整它的大小,它看起来很好,但由于某种原因,调整大小会使它变得一团糟。我在使用ios7并在iPhone 5s上进行测试
发布于 2014-02-26 19:14:14
UIGraphicsBeginImageContext(newSize);
[image drawInRect:newRect];
UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();我用的是self.image drawInRect而不是图像drawInRect愚蠢的错误。哇。
https://stackoverflow.com/questions/22031824
复制相似问题