Premultiplied Colour Blending

Everything else that doesn't fall into one of the other PB categories.
sq4
User
User
Posts: 98
Joined: Wed Feb 26, 2014 3:16 pm
Contact:

Premultiplied Colour Blending

Post by sq4 »

Purebasic gives the possibility to display a sprite in a certain monochrome color.

Code: Select all

DisplayTransparentSprite(#Sprite, x, y [, Intensity [, Color]])
The idea behind this (IMHO) must be to display it in combination with the same sprite in a certain blending mode to colorize.

Most of the time this works! So, I must be on the right track...
But something is weird and I think it has to do with the fact that the monochrome colored sprite's RGB component isn't premultiplied with it's alpha component.

Let me explain:

I draw the original sprite first like this

Code: Select all

SpriteBlendingMode(#PB_Sprite_BlendSourceAlpha,#PB_Sprite_BlendInvertSourceAlpha)
DisplayTransparentSprite(#Sprite,x,y,Alpha)
And then I layer the same sprite over it like this

Code: Select all

SpriteBlendingMode(#PB_Sprite_BlendDestinationColor,#PB_Sprite_BlendInvertSourceAlpha)
DisplayTransparentSprite(#Sprite,x,y,255, Color)
I can also use this for the second sprite :

Code: Select all

SpriteBlendingMode(#PB_Sprite_BlendDestinationColor,#PB_Sprite_BlendInvertDestinationAlpha)
DisplayTransparentSprite(#Sprite,x,y,255, Color)
Both methods give different results depending on the ClearScreen(Color).

So my questions :
- Is it true that Purebasic monochrome colored sprites are ment to be used for color compositing?
- Why no premultiply?


Hope this makes sense... :wink:
A nice explanation what I try to achieve :
http://amindforeverprogramming.blogspot ... nding.html