GPUImage: blending two images

Nikita picture Nikita · Jul 23, 2012 · Viewed 9.7k times · Source

I was using GPUImage framework (some old version) to blend two images (adding border overlay to a certain image). After I have updated to latest framework version, after applying such a blend, I get an empty black image.

I'm using next method:

- (void)addBorder {
    if (currentBorder != kBorderInitialValue) {
        GPUImageAlphaBlendFilter *blendFilter = [[GPUImageAlphaBlendFilter alloc] init];
        GPUImagePicture *imageToProcess = [[GPUImagePicture alloc] initWithImage:self.imageToWorkWithView.image];
        GPUImagePicture *border = [[GPUImagePicture alloc] initWithImage:self.imageBorder];

        blendFilter.mix = 1.0f;
        [imageToProcess addTarget:blendFilter];
        [border addTarget:blendFilter];

        [imageToProcess processImage];
        self.imageToWorkWithView.image = [blendFilter imageFromCurrentlyProcessedOutput];

        [blendFilter release];
        [imageToProcess release];
        [border release];
    }
}

What is the problem?

Answer

Brad Larson picture Brad Larson · Jul 23, 2012

You're forgetting to process the border image. After [imageToProcess processImage], add the line:

[border processImage];

For a two images being input into a blend, you have to use -processImage on both after they have been added to the blend filter. I changed the way that the blend filter works in order to fix some bugs, and this is how you need to do things now.