Blending with GPUImage: How to control the position of the second image on top of the first

纵饮孤独 提交于 2019-12-11 23:34:49

问题


I use the following code to blend two images using GPUImage framework by Brad Larson. Is there a way to control the position of the topImage relatively to the baseImage? Now, it places topImage on the middle of baseImage.

GPUImageMultiplyBlendFilter *overlayBlendFilter = [[GPUImageMultiplyBlendFilter alloc] init];
GPUImagePicture *pic1 = [[GPUImagePicture alloc] initWithImage:baseImage];
GPUImagePicture *pic2 = [[GPUImagePicture alloc] initWithImage:topImage];

[pic1 addTarget:overlayBlendFilter];
[pic1 processImage];
[pic2 addTarget:overlayBlendFilter];
[pic2 processImage];

UIImage *blendedImage = [overlayBlendFilter imageByFilteringImage:filteredimage];

[imageView setImage:blendedImage];

回答1:


You'll need to use one or two GPUImageTransformFilters after your pictures, but before your blend, in order to size and scale your pictures as needed.

By default, the framework stretches one image to fit the dimensions of the other, so you need to account for that using an appropriate transform that you apply to one or both of the images. You need to do this before the blend, so that they are blended properly.



来源:https://stackoverflow.com/questions/20031006/blending-with-gpuimage-how-to-control-the-position-of-the-second-image-on-top-o

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!