0
我想用alpha和multiply使用GPUImage將其中一個圖像疊加在另一個圖像上。在Core Graphics中,這是我正在做的。使用乘法和alpha來繪製另一個GPUImage
CGContextRef ctx = UIGraphicsGetCurrentContext();
UIImage* baseImage = ...;
UIImage* overImage = ...;
CGSize size = baseImage.size;
// Draw the base image
CGContextDrawImage(ctx, CGRectMake(0, 0, size.width, size.height), baseImage.CGImage);
//Draw the overlay
CGContextSetAlpha(ctx, .5);
CGContextSetBlendMode(ctx, kCGBlendModeMultiply);
CGContextDrawImage(ctx, CGRectMake(0, 0, size.width, size.height), overImage.CGImage);
,當我嘗試做使用GPUImage我可以要麼乘或字母來解決這個同樣的事情,但我不能讓他們兩人的工作。我覺得有一些結合我不明白的GPUImage過濾器。這是我用GPUImage做的許多不同嘗試中的一個,以使其發揮作用。這個版本的代碼是做乘法而不是alpha。
GPUImagePicture *pictureOverlay = [[GPUImagePicture alloc] initWithImage:overImage];
GPUImageOpacityFilter* opacityFilter = [[GPUImageOpacityFilter alloc] init];
opacityFilter.opacity = .5;
[pictureOverlay addTarget:opacityFilter];
[pictureOverlay processImage];
pictureOverlay = [[GPUImagePicture alloc] initWithImage:[opacityFilter imageFromCurrentlyProcessedOutput]];
GPUImagePicture *pictureBase = [[GPUImagePicture alloc] initWithImage:baseImage];
GPUImageMultiplyBlendFilter *filter = [[GPUImageMultiplyBlendFilter alloc] init];
[pictureBase addTarget:filter];
[pictureOverlay addTarget:filter];
UIImage* finalImage = [filter imageFromCurrentlyProcessedOutput];
任何幫助將不勝感激。
以下是我使用Core Graphics進行處理時的圖像。
這裏是我所得到的,當我使用GPUImage
感謝您的迴應!我用我想要實現的圖像輸出和使用上面的代碼使用GPUImage時得到的輸出來更新我的原始文章。顏色看起來不對。 –