2012-03-31 20 views
2

私はAVAssetWriterInputPixelBufferAdaptorを使用してUIImageの配列 からビデオを作成しています。異なる形式のアニメーション(スライドショーと同じように)から別の画像へのトランジションを変更します。 ..実際はスライドショーのように)。UIImage(UIImageViewではありません)の透明度を変更します

これらの移行スタイルの1つがフェードアウトします。そのようなイム書き込みUIImages以来 ...

UIImage *image = imageView.image; 
    UIImage *resizedImage = [ICVideoViewController imageWithImage:image scaledToSize:CGSizeMake(640, 480)]; 
    CGImageRef img = [resizedImage CGImage]; 
    CVPixelBufferRef buffer = [ICVideoViewController pixelBufferFromCGImage:img size:CGSizeMake(640, 480)]; 

    [adaptor appendPixelBuffer:buffer withPresentationTime:CMTimeMake(i, 1)]; 

私はこれを達成することが可能である場合 (手動ピクセルを操作しなくても)知っていただきたいと思いますか..?

答えて

2

私はあなたのView Controllerのimagawithimage関数でイメージをどのように作成しているのか知りません。

CGContextを使用して画像を拡大する場合は、CGContextDrawImage()の前にCGContextSetAlpha()を使用してください。

あなたはもう一つ、あなたはそのためのより多くの数行をコーディングする必要があります疑いを行うことができますが、これは一方通行できない場合は、次の

CGSize size = [self size]; 
int width = size.width; 
int height = size.height; 

// the pixels will be painted to this array 
uint32_t *pixels = (uint32_t *) malloc(width * height * sizeof(uint32_t)); 

// clear the pixels so any transparency is preserved 
memset(pixels, 0, width * height * sizeof(uint32_t)); 

CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 

// create a context with RGBA pixels 
CGContextRef context = CGBitmapContextCreate(pixels, width, height, 8, width * sizeof(uint32_t), colorSpace, 
              kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedLast); 

// paint the bitmap to our context which will fill in the pixels array 
CGContextSetAlpha(context, 0.5); 
CGContextDrawImage(context, CGRectMake(0, 0, width, height), [self CGImage]); 
CGImageRef image = CGBitmapContextCreateImage(context); 

CGContextRelease(context); 
CGColorSpaceRelease(colorSpace); 
free(pixels); 
関連する問題