GPUImage: Blending Two Images

I used the GPUImage framework (some old version) to mix two images (adding a border overlay to a specific image). After I updated to the latest version of the framework, after applying this combination, I get a blank black image.

I am using the following 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?

+7
source share
2 answers

You forget to process the border image. After [imageToProcess processImage] add the line:

 [border processImage]; 

For two images to be -processImage to the mix, you should use -processImage for both after adding them to the blending filter. I changed the way the blend filter works to fix some errors, and here is what you need to do now.

+11
source

This is the code that I use to merge two images with GPUImageAlphaBlendFilter.

 GPUImagePicture *mainPicture = [[GPUImagePicture alloc] initWithImage:image]; GPUImagePicture *topPicture = [[GPUImagePicture alloc] initWithImage:blurredImage]; GPUImageAlphaBlendFilter *blendFilter = [[GPUImageAlphaBlendFilter alloc] init]; [blendFilter setMix:0.5]; [mainPicture addTarget:blendFilter]; [topPicture addTarget:blendFilter]; [blendFilter useNextFrameForImageCapture]; [mainPicture processImage]; [topPicture processImage]; UIImage * mergedImage = [blendFilter imageFromCurrentFramebuffer]; 
+6
source

All Articles