spot icon indicating copy to clipboard operation
spot copied to clipboard

consider these

Open r-lyeh-archived opened this issue 10 years ago • 3 comments

Photoshop-style blend equations with destination alpha

The photoshop blend formulas are available in many places on the web, but
they all assume an opaque output target. Sometimes the output target is not
opaque (for example, with layer folders in Photoshop and the blend mode
not set to "normal").

The following formulas appear to be the ones used by Adobe Flash Player;
they might differ from Photoshop blend modes, and they do not include all of
the Photoshop blend modes (these formulas were developed for and verified in
Iggy, software I wrote for RAD Game Tools which "plays" Adobe Flash files).

                   out color                                                    out alpha
                   --------------                                               -----------
layer/over:    (   sc+(1-sa)*dc                                              ,  sa+da-sa*da   )
multiply:      (   sc*dc                                                     ,  sa+da-sa*da   )
screen:        (   sa*da - (da-dc)*(sa-sc)                                   ,  sa+da-sa*da   )
lighten:       (   max(sa*dc,sc*da)                                          ,  sa+da-sa*da   )
darken:        (   min(sa*dc,sc*da)                                          ,  sa+da-sa*da   )
add:           (   min(dc+sc,1)                                              ,  min(sa+da,1)  )
subtract:      (   max(dc-sc,0)                                              ,  min(sa+da,1)  )
difference:    (   abs(sa*dc-sc*da)                                          ,  sa+da-sa*da   )
invert:        (   sa*(da-dc)                                                ,  sa+da-sa*da   )
overlay:       (   dc < da/2.0 ? (2.0*sc*dc) : (sa*da - 2.0*(da-dc)*(sa-sc)) ,  sa+da-sa*da   )
hardlight:     (   sc < sa/2.0 ? (2.0*sc*dc) : (sa*da - 2.0*(da-dc)*(sa-sc)) ,  sa+da-sa*da   )

  sc = source color, sa = source alpha, dc = dest color, da = dest alpha

The inputs in the above equations must be premultiplied. If inputs are
non-premultiplied, replace "sc" with "sc*sa". (Outputs are always
premultiplied, hence destination is always premultiplied.)

-- Sean Barrett, 2012/09/19

r-lyeh-archived avatar Sep 20 '14 10:09 r-lyeh-archived

composition http://ssp.impulsetrain.com/porterduff.html

utils https://github.com/mayanklahiri/easyexif https://code.google.com/p/imageresampler/ https://github.com/nothings/stb/blob/master/stb_image_resize.h https://github.com/pornel/undither https://github.com/rflynn/imgmin https://github.com/pornel/pngquant https://github.com/progschj/reziretsar https://github.com/a1k0n/texturesynth

formats ~~https://github.com/syoyo/tinyexr~~ https://github.com/aras-p/miniexr https://github.com/gameclosure/gcif ~~https://code.google.com/p/crunch/~~ almost in http://www.jonolick.com/home/dxt-compression-part-4-entropy https://software.intel.com/en-us/articles/fast-ispc-texture-compressor-update ~~https://bitbucket.org/wolfpld/etcpak/wiki/Home~~ ~~https://bitbucket.org/jthlim/pvrtccompressor~~ https://github.com/r-lyeh/rgba332 https://github.com/ARM-software/astc-encoder https://github.com/castano/nvidia-texture-tools/tree/master/src BCs https://github.com/GameTechDev/ISPCTextureCompressor http://www.antigrain.com/lite/agg2_lite.zip https://github.com/google/image-compression ~~https://github.com/FLIF-hub/FLIF~~ (decoder is apache 2.0 licensed now) https://gist.github.com/urraka/685d9a6340b26b830d49/ http://www.jonolick.com/uploads/7/9/2/1/7921194/jo_mpeg.cpp http://www.jonolick.com/uploads/7/9/2/1/7921194/jo_gif.cpp

r-lyeh-archived avatar Dec 03 '14 18:12 r-lyeh-archived

@templeblock wat? :D

r-lyeh-archived avatar Feb 01 '16 15:02 r-lyeh-archived

^_^

templeblock avatar Feb 01 '16 15:02 templeblock