Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Blending more then 2 BlendFilters #597

shshalom opened this Issue · 4 comments

2 participants


Hey Brad,

I'm trying to blend more then two filters (With Images) on top live camera.
I've manage to blend 2 images with blendFilters but when I chained the third filter I get black screen.

Is it possible? and if so what is the right way to do this.



Could you provide the code you're using to blend these three filters? That might help to figure out what's going wrong.

videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack];
videoCamera.outputImageOrientation = UIInterfaceOrientationPortrait;

GPUImageView *filterView = (GPUImageView *)self.view;

GPUImageScreenBlendFilter *screen = [[GPUImageScreenBlendFilter alloc] init];
 [videoCamera addTarget:screen];

 UIImage *layer1 = [UIImage imageNamed:@"f12_03_screen.png"];
 sourcePicture = [[GPUImagePicture alloc] initWithImage:layer1 smoothlyScaleOutput:YES];
 [sourcePicture processImage];
 [sourcePicture addTarget:screen];

 GPUImageMultiplyBlendFilter *multiply2 = [[GPUImageMultiplyBlendFilter alloc] init];
 [screen addTarget:multiply2];

 UIImage *layer2 = [UIImage imageNamed:@"f12_04_multiply.png"];
 sourcePicture = [[GPUImagePicture alloc] initWithImage:layer2 smoothlyScaleOutput:YES];
 [sourcePicture processImage];
 [sourcePicture addTarget:multiply2];

GPUImageOverlayBlendFilter *overlay3 = [[GPUImageOverlayBlendFilter alloc] init];
[multiply2 addTarget:overlay3];

UIImage *layer3 = [UIImage imageNamed:@"f12_08_overlay.jpg"];
 sourcePicture = [[GPUImagePicture alloc] initWithImage:layer3 smoothlyScaleOutput:YES];
 [sourcePicture processImage];
 [sourcePicture addTarget:overlay3];

 [overlay3 addTarget:filterView];

 [videoCamera startCameraCapture];


Is this ARC-enabled code? If so, you're deallocating your source images. You need to hold on to them as instance variables, or they will go away as soon as you leave this method. This can cause bizarre behavior, including black images and crashes.


Yes, that was my mistake.

Thank you!!!

@BradLarson BradLarson closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.