1

这是我正在使用的代码。我想生成缩略图,然后我通过这些缩略图创建一个视频,并在“drawImage”UIImageView 上完成绘图。

   while([self.thunbnailArray count])
    {
        id times = [self.thunbnailArray objectAtIndex:0];////self.thumbnailArray contains duratin of player at which thumbnail generate//////
        [self.thunbnailArray removeObjectAtIndex:0];
        UIImage* thumbnail = [player1 thumbnailImageAtTime:[times floatValue]             timeOption:MPMovieTimeOptionExact];

        UIGraphicsBeginImageContext(drawImage.frame.size);////drawImage is a UIImageView to make drawing
        [drawImage.layer renderInContext:UIGraphicsGetCurrentContext()];
        UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();

        CGImageRef firstImageRef = thumbnail.CGImage;/////merge thumbnail and drawing both together
        CGFloat firstWidth = CGImageGetWidth(firstImageRef);
        CGFloat firstHeight = CGImageGetHeight(firstImageRef);
        CGSize mergedSize = CGSizeMake(firstWidth, firstHeight);
        UIGraphicsBeginImageContext(mergedSize);
        [thumbnail drawInRect:CGRectMake(0, 0, firstWidth, firstHeight)];
        [viewImage drawInRect:CGRectMake(0, 0, firstWidth, firstHeight)];
        UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
        [self.imageArray addObject:newImage];///self.imageArray used to generate video

    }
4

0 回答 0