Jump to content

Coornio

Members
  • Posts

    28
  • Joined

  • Last visited

Community Answers

  1. Coornio's post in About blend modes and their code was marked as the answer   
    As is the usual after one posts a lengthy post requesting help, I managed to solve it with the help of another third party. For those curious:

     
    weightSrc = Asrc / 255; weightDst = 1 - weightSrc; Aout = min(Adst * weightDst + Asrc, 255); Rout = min(Rdst * weightDst + BLEND * weightSrc, 255); Gout = min(Gdst * weightDst + BLEND * weightSrc, 255); Bout = min(Bdst * weightDst + BLEND * weightSrc, 255); // where BLEND stands for the particular blend operation you require, // eg: Difference is: abs(Rsrc - Rdst) // eg: Multiply is: (Rsrc * Rdst) / 255 // eg: Additive is: min(Rsrc + Rdst, 255) // normal alpha blending in particular is easier Aout = min(Adst * weightDst + Asrc, 255); Rout = min(Rdst * weightDst + (Rsrc * Asrc) / 255, 255); Gout = min(Gdst * weightDst + (Gsrc * Asrc) / 255, 255); Bout = min(Bdst * weightDst + (Bsrc * Asrc) / 255, 255);  
    I am not 100% sure if I haven't made any mistakes, but some rudimentary testing through the color picker in a comparison between paint.NET's blend and mine shows practically identical values, minus rounding differences.
×
×
  • Create New...