# XNA Subtract blending function doesn't work

I wanted to subtract a white image with black circle background from a picture to get a lighting circle here is the white image So I wrote this code

spriteBatch.Begin(SpriteSortMode.Deferred, new BlendState
{
ColorBlendFunction = BlendFunction.Subtract,
AlphaBlendFunction = BlendFunction.Subtract
});
//Draw the white image with black circle
spriteBatch.Draw(test, new Vector2(), Color.White);
spriteBatch.End();


I was aiming to get difference between it and the background image rendered to get something like this

But the result that the first image is only drawn while second is below it

• Couldn't you simply do this with alpha blending? – Andrew Russell Feb 23 '12 at 14:18

Just set the below as the BlendState in SpriteBatch.Begin(). Also worth noting is that if the SortMode is SpriteSortMode.Immediate you can alter the all of the GraphicsDevice's properties without calling Spritebatch.Begin again.

        GraphicsDevice.BlendState = new BlendState {

ColorSourceBlend = Blend.Zero,
ColorDestinationBlend = Blend.InverseSourceColor,

AlphaSourceBlend = Blend.Zero,