Jump to content
Paint.NET 5.1 is now available! ×

Recommended Posts

Posted

Hello all, sorry I am new and need some help, it's not really related to Paint.NET usage, but how it calculate the resulting color:

 

For example I make red background, call it C1:

 

RGBA = 255, 0, 0, 255

 

Then I place a yellow pixel, call it C2:

 

RGBA: 220, 216, 0, 200

 

Then I use the Color Picker tool on this pixel, I get C3:

 

RGBA: 227, 169, 0, 255

 

 

I already know how to calculate R, G, and B of C3

 

R = ( (C2.A / 255) * C2.R ) + ( (1 - (C2.A / 255)) * C1.R ) = 227

G = ( (C2.A / 255) * C2.G ) + ( (1 - (C2.A / 255)) * C1.G ) = 169

B = ( (C2.A / 255) * C2.B ) + ( (1 - (C2.A / 255)) * C1.B ) = 0

 

 

But for the Alpha channel, it is different and I can't find how to calculate it!

 

Thanks for any help :)

 

Posted (edited)

Of course, that was a bad example then... Ok another example.

 

C1 alpha is 128, C2 alpha is also 128, the resulting alpha is 192.

 

Another

 

C1 alpha is 250, C2 alpha is 200, the resulting alpha is 254.

 

How to calculate this?

 

 

Edit: is this correct:

 

floor( 255 - ( ((255 / C1.A) * C2.A) + ((1 - (C2.A / 255)) * C1.A) ) )

 

But now I realized the other calcualtions are wrong...

 

Edit again: solved.

Edited by guix
Posted (edited)

No but problem solved, the whole thing was wrong because I used values between 0 and 255 when I should have used values between 0 and 1.

 

Thanks anyway :)

Edited by guix

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...