与GPUImage融合:如何控制第二个图像在第一个图像之上的位置 [英] Blending with GPUImage: How to control the position of the second image on top of the first

查看:205
本文介绍了与GPUImage融合:如何控制第二个图像在第一个图像之上的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码使用Brad Larson的GPUImage框架混合两个图像. 有没有一种方法可以控制topImage相对于baseImage的位置?现在,它将topImage放置在baseImage的中间.

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];

推荐答案

您需要在图片之后但在混合之前使用一个或两个GPUImageTransformFilters,以便根据需要调整图片的大小和比例.

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.

这篇关于与GPUImage融合:如何控制第二个图像在第一个图像之上的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆