title: Blending one image onto another gives incorrect image because of alpha value
body: <p>So I have an issue blending two images together dealing with transparency. I am using freetype here for generating the glyphs.I have a rather large codebase so I picked out the major portions of the code that are involved in the blending process.</p>
  
  <p>This is the code i am using:</p>
  
  <pre><code>void TopDown(FT_Bitmap *bitmap, ... )
  {
          .....
          .....
  
          for (int srcY=0; srcY &lt; bitmap-&gt;rows; srcY++, destLine += textureWidth, srcLine += bitmap-&gt;pitch)
          {
              unsigned char *currSrc = srcLine;
              unsigned int *currDest = destLine;
              for (int srcX=0; srcX &lt; bitmap-&gt;width; srcX++, currSrc++)
              {
                  unsigned char alpha = *currSrc * textA / 255;
                  if (currDest &gt;= dest &amp;&amp; currDest &lt; destMax)
                  {
                      unsigned int destR = (textR * alpha + bgR * (255-alpha))/255;
                      unsigned int destG = (textG * alpha + bgG * (255-alpha))/255;
                      unsigned int destB = (textB * alpha + bgB * (255-alpha))/255;
  
                      unsigned int as = alpha;
                      *currDest = makeColor(destR, destG, destB, alpha);
                  }
                  currDest++;
              }
          }
  }
  </code></pre>