使用强光混合模式时的Higlight伪像 [英] Higlight Artifacts When Using Hard Light Blend Mode

查看:55
本文介绍了使用强光混合模式时的Higlight伪像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用顶部图像的HardLight混合模式在iPhone应用程序中混合两个图像。看起来像这样:

I'm blending two images in my iPhone app, using the HardLight blend mode of the top image. It looks something like this:

UIGraphicsBeginImageContext(size);
[sourceImage drawInRect:rectangle blendMode:kCGBlendModeNormal alpha:1.0];
[effectOverlay drawInRect:rectangle blendMode:kCGBlendModeHardLight alpha:0.75];
mainImage.image =  UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

工作正常。但是,图像中吹出的高光会出现怪异的颜色伪影。请注意此照片右下角的紫色伪像:

It works fine. However, the blown-out highlights in the image appear with a weird color artifact. Note the purple artifact in the bottom-right corner of this photo:

http://dl.dropbox.com/u/626891/artifact.jpg http://dl.dropbox.com/u/626891/artifact.jpg

这仅在使用强光时发生;其他混合模式也可以。有人知道该怎么办吗?

This only occurs using Hard Light; other blend modes are fine. Anyone know what to do about this?

推荐答案

这个问题很烦人。

不过,这是另一种解决方法,它比我在这里看到的即席方法更能可靠地解决问题。对我不起作用)。知道混合模式HardLight与Overlay相同,只是在切换两个参数的情况下很有用。事实是,Overlay的iOS实现不是不是越野车。因此,您需要四处移动图形(并可能使用 UIGraphicsGetImageFromCurrentImageContext 等进行中间快照),以便以切换的顺序绘制两个图像。这样,您可以使用Overlay而不是HardLight。

Nevertheless, here is another workaround which seems better suited to solve the problem more reliably than the adhoc approaches I see here (which did not work for me). It is useful to know that the blend mode HardLight is the same as Overlay, only with the two arguments switched. And the things is that the iOS implementation of Overlay is not buggy. So you need to move around your drawing (and maybe take an intermediate snap shot with UIGraphicsGetImageFromCurrentImageContext or the like) such that you draw your two images in a switched order. This way you can use Overlay instead of HardLight.

因此,对于您的示例,将代码更改为:

So, for your example change the code to:

    UIGraphicsBeginImageContext(size);
    [effectOverlay drawInRect:rectangle blendMode:kCGBlendModeNormal alpha:0.75];
    [sourceImage drawInRect:rectangle blendMode:kCGBlendModeOverlay alpha:1.0];
    mainImage.image =  UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

希望这会有所帮助。

这篇关于使用强光混合模式时的Higlight伪像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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