2014-02-26 41 views
2

即時通訊嘗試調整從使用MPImagePickerController使用MPMoviePlayerController捕獲的視頻縮略圖。這裏是使用何種即時通訊:調整從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拍攝的照片,但由於某種原因,圖像是空白的,當我用它在視頻縮略圖上。如果我不重新調整它,它看起來很好,但由於某種原因調整它調整了它。即時通訊使用在iPhone ios7和測試5S

回答

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

我用[self.image drawInRect]而非[圖像drawInRect]愚蠢的錯誤。哇。