justin = { main feed , music , code , askjf , pubkey };
Ask Justin Frankel
No reasonable question unanswered since 2009!

Suggested topics: programming, music, sleep, coffee, etc.

Note: please do not ask questions about REAPER features, bugs or scheduling, use the forums instead.


Name: Ask: Human (enter yes):
[back to index] | [unreplied] | [replied] | [recent comments] | [all]

Question: UpdateLayeredWindow: should i multiply each pixel rgb values with its alpha? how? value
Asked by ruchira (175.157.19.x) on February 8 2012, 3:44am
Reply on February 8 2012, 5:04am (edited at February 8 2012, 5:05am):
    Ah yeah, it wants premultiplied alpha, I forgot about that:
    
    void pf(LICE_pixel *p, void *parm)
    {
      int a = LICE_GETA(*p) + 1;
    
      // not technically correct, removing the +1/-1 and changing /256 to /255
      // would be more correct (and also quite a bit slower).
      *p  = LICE_RGBA(
               (LICE_GETR(*p)*a)/256,
               (LICE_GETG(*p)*a)/256,
               (LICE_GETB(*p)*a)/256,
               a-1);
    }
    
    LICE_ProcessRect(&a,0,0,a.getWidth(),a.getHeight(),pf,NULL);
    
    
    (This would also mangle the buffer, so you'd want to do it in a temporary buffer if you don't redraw every frame completely)

Comment:
    Your Name:   -- Site Owner's Name:  (for human-verification)

    Comment:    

    
  
[back to index] | [unreplied] | [replied] | [recent comments] | [all]
Copyright 2025 Justin Frankel. | RSS