guix Posted January 22, 2013 Share Posted January 22, 2013 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 Quote Link to comment Share on other sites More sharing options...
BoltBait Posted January 22, 2013 Share Posted January 22, 2013 If you place a simi-transparent pixel on top of a fully opaque pixel, the result will be a fully opaque pixel. Quote Click to play: Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game Link to comment Share on other sites More sharing options...
guix Posted January 23, 2013 Author Share Posted January 23, 2013 (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 January 23, 2013 by guix Quote Link to comment Share on other sites More sharing options...
BoltBait Posted January 23, 2013 Share Posted January 23, 2013 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. Alpha 128 is half opaque. So, half opaque plus another half (of what's left) is three quarters opaque. 192 is three quarters of 255. Clear? Quote Click to play: Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game Link to comment Share on other sites More sharing options...
guix Posted January 23, 2013 Author Share Posted January 23, 2013 (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 January 23, 2013 by guix Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.