title: XNA BlendState with SpriteBatch
body: <p>We are needing a BlendState to act as the following:</p>
  
  <ul>
  <li>Transparent PNGs are drawn as expected, with anything behind them preserved</li>
  <li>We use <code>Color.White</code> to draw a PNG as-is</li>
  <li>We will change the alpha channel of the color to change the "opacity" of the texture</li>
  </ul>
  
  <p>To get this effect, <code>BlendState.AlphaBlend</code> is close, but draws white as the transparent part if we set alpha to 100 or any number other than 255.</p>
  
  <p>So we attempted this:</p>
  
  <pre><code>        _blendState = new BlendState();
          _blendState.AlphaSourceBlend = Blend.SourceAlpha;
          _blendState.AlphaDestinationBlend = Blend.InverseSourceAlpha;
          _blendState.ColorSourceBlend = Blend.SourceAlpha;
          _blendState.ColorDestinationBlend = Blend.InverseSourceAlpha;
  </code></pre>
  
  <p>This works, except we now get undesired effects if two PNGs are on top of one another.  Basically we get some weird lines where it looks like pixel data is being added (or something).</p>
  
  <p>Example:</p>
  
  <p><img src="https://i.stack.imgur.com/QKJjS.png" alt="enter image description here"></p>
  
  <p>Effectively, <code>BlendState.AlphaBlend</code> is this:</p>
  
  <pre><code>        _blendState = new BlendState();
          _blendState.AlphaSourceBlend = Blend.SourceAlpha;
          _blendState.AlphaDestinationBlend = Blend.InverseSourceAlpha;
          _blendState.ColorSourceBlend = Blend.One;
          _blendState.ColorDestinationBlend = Blend.InverseSourceAlpha;
  </code></pre>
  
  <p>Image looks better than above:</p>
  
  <p><img src="https://i.stack.imgur.com/Wh1HB.png" alt="enter image description here"></p>
  
  <p>But then alpha doesn't work, using 100 as alpha would replace the background with white.</p>
  
  <p>What <code>BlendState</code> should we use to get our desired effect from SpriteBatch?  We are OK to use a different color such as <code>Color.Black</code> there is another way to get it to work.</p>
  
  <p>*PS - another nice feature would be if we could use <code>Color.Red</code> to "tint" a texture, but we want it to work in general first.</p>