我正在尝试使用相机Feed的输出执行Overlay Blend
股票图像,其中股票图像的不透明度低于100%。我想我可以在过滤器堆栈中放置GPUImageOpacityFilter
,一切都会好的:
但是导致的不是GPUImagePicture的0.1f alpha版本混合到GPUImageVideoCamera中,它导致有点软化GPUImagePicture的颜色/对比度并混合它。所以我做了一些搜索,并尝试使用imageFromCurrentlyProcessedOutput
从GPUImageOpacity过滤器中取出UIImage并将其发送到BlendFilter:
这完全符合我的预期。那么,为什么我必须imageFromCurrentlyProcessedOutput
,那不应该只是排队吗?以下是上述两种情况的代码snippits:
第一个:
//Create the GPUPicture
UIImage *image = [UIImage imageNamed:@"someFile"];
GPUImagePicture *textureImage = [[[GPUImagePicture alloc] initWithImage:image] autorelease];
//Create the Opacity filter w/0.5 opacity
GPUImageOpacityFilter *opacityFilter = [[[GPUImageOpacityFilter alloc] init] autorelease];
opacityFilter.opacity = 0.5f
[textureImage addTarget:opacityFilter];
//Create the blendFilter
GPUImageFilter *blendFilter = [[[GPUImageOverlayBlendFilter alloc] init] autorelease];
//Point the cameraDevice's output at the blendFilter
[self._videoCameraDevice addTarget:blendFilter];
//Point the opacityFilter's output at the blendFilter
[opacityFilter addTarget:blendFilter];
[textureImage processImage];
//Point the output of the blendFilter at our previewView
GPUImageView *filterView = (GPUImageView *)self.previewImageView;
[blendFilter addTarget:filterView];
第二个:
//Create the GPUPicture
UIImage *image = [UIImage imageNamed:@"someFile"];
GPUImagePicture *textureImage = [[[GPUImagePicture alloc] initWithImage:image] autorelease];
//Create the Opacity filter w/0.5 opacity
GPUImageOpacityFilter *opacityFilter = [[[GPUImageOpacityFilter alloc] init] autorelease];
opacityFilter.opacity = 0.5f
[textureImage addTarget:opacityFilter];
//Process the image so we get a UIImage with 0.5 opacity of the original
[textureImage processImage];
UIImage *processedImage = [opacityFilter imageFromCurrentlyProcessedOutput];
GPUImagePicture *processedTextureImage = [[[GPUImagePicture alloc] initWithImage:processedImage] autorelease];
//Create the blendFilter
GPUImageFilter *blendFilter = [[[GPUImageOverlayBlendFilter alloc] init] autorelease];
//Point the cameraDevice's output at the blendFilter
[self._videoCameraDevice addTarget:blendFilter];
//Point the opacityFilter's output at the blendFilter
[processedTextureImage addTarget:blendFilter];
[processedTextureImage processImage];
//Point the output of the blendFilter at our previewView
GPUImageView *filterView = (GPUImageView *)self.previewImageView;
[blendFilter addTarget:filterView];