Custom blend modes
Posted: 2007-07-11T04:44:57-07:00
Hi,
I'm totally stuck trying to implement Photoshop blending modes. There is a great website with all of the blending modes explained: http://www.simplefilter.de/en/grundlagen/mixmods.html
For example I tried to implement the Linear Light blending mode. Here is a code snippet from my LinearLight method (it is called by CompositeLinearLight, which is just a copy/paste of existing composite ops in ImageMagick):
Linear Light formula: C=B+2*A-1, where C=result B=destination pixel A=source pixel and A,B,C are all in [0;1] range.
part is the actual foruma from the website and the rest is an attempt to blend the result correctly.
This snipped is based on the existing Multiply composite op in ImageMagick. Unfortunately the result is totally wrong. I believe something is wrong with the blending of the result, but I just have no idea what. Anyone could help me by writing an example of how the blend modes should be written in ImageMagic? I would gladly implement the rest of them and submit a patch.
Thank you!
I'm totally stuck trying to implement Photoshop blending modes. There is a great website with all of the blending modes explained: http://www.simplefilter.de/en/grundlagen/mixmods.html
For example I tried to implement the Linear Light blending mode. Here is a code snippet from my LinearLight method (it is called by CompositeLinearLight, which is just a copy/paste of existing composite ops in ImageMagick):
Linear Light formula: C=B+2*A-1, where C=result B=destination pixel A=source pixel and A,B,C are all in [0;1] range.
Code: Select all
pixel=(((1.0-QuantumScale*beta)*q*QuantumScale)+2*((1.0-QuantumScale*alpha)*p*QuantumScale)-1.0)*QuantumRange+(1.0-QuantumScale*alpha)*p*QuantumScale*beta+(1.0-QuantumScale*beta)*q*
QuantumScale*alpha;
Code: Select all
(((1.0-QuantumScale*beta)*q*QuantumScale)+2*((1.0-QuantumScale*alpha)*p*QuantumScale)-1.0)*QuantumRange
This snipped is based on the existing Multiply composite op in ImageMagick. Unfortunately the result is totally wrong. I believe something is wrong with the blending of the result, but I just have no idea what. Anyone could help me by writing an example of how the blend modes should be written in ImageMagic? I would gladly implement the rest of them and submit a patch.
Thank you!