How can I mix two ARGB pixels ?
Example
Here A is (Red with Alpha) and B is ( Blue with Alpha ).
How can I mix two ARGB pixels ?
Example
Here A is (Red with Alpha) and B is ( Blue with Alpha ).
Taken from the same Wikipedia article where you got the image:
Translating to values which range from 0 to 255:
rOut = (rA * aA / 255) + (rB * aB * (255 - aA) / (255*255))
gOut = (gA * aA / 255) + (gB * aB * (255 - aA) / (255*255))
bOut = (bA * aA / 255) + (bB * aB * (255 - aA) / (255*255))
aOut = aA + (aB * (255 - aA) / 255)
The above is the wrong algorithm. This can be verified by substituting aA = 0. Then it turns out that if you are trying to blend color B with completely transparent color A, i.e. invisible, then logically the color B remains unchanged, but according to this formula it will be changed. The result of incorrect blending with gradient transparency. Therefore, the correct solution would be like this:
aOut = aA + (aB * (255 - aA) / 255)
rOut = (rA * aA + rB * aB * (255 - aA) / 255)/aOut
gOut = (gA * aA + gB * aB * (255 - aA) / 255)/aOut
bOut = (bA * aA + bB * aB * (255 - aA) / 255)/aOut
It seems like this is what you want: http://en.wikipedia.org/wiki/Alpha_compositing#Alpha_blending, but I m a little confused by your notation since wikipedia says that argb values should range from 0.0 to 1.0. So I don t think this formula will give you FA=19. Can you clarify?
Edit: now that you took out the business about FA=19, I m inclined to go with that formula.
I am trying to create a 3D robot that should perform certain actions when certain body parts are clicked. I have successfully (sort of) implemented picking in that if you click on any x-plane part, it ...
I m using CCSS to generate smooth surfaces. I ve been using the regular subdivision rules to interpolate the surface/vertex normal, but I think this may be wrong. Are there different stencils to ...
My company needs 3D visualization for our commercial applications (CAD, mesh manipulation, computational geometry). We are tired of true vision 3D (tv3d), which we ve been using for years (poor ...
I am from .net C# background and I want to learn DirectX. I have knowledge of C++ but I am fairly new to graphic world. I am little confused about how to start learning directx, should I start ...
I have to write an algorithm in AS3.0 that plots the location of points radially. I d like to input a radius and an angle at which the point should be placed. Obviously I remember from geometry ...
I need to determine roughly how much VRAM a system s graphics card has. I know all the reasons why I shouldn t but I do. It doesn t need to be perfect (some cards lie etc.) but I need a ballpark. On ...
I know that there are already 2 relevant posts on that, but it s not clear... So the case is this...: I have a UIImage which consists of a png file requested from a url on the net. Is it possible to ...
I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...