Reputation: 261
I am trying to draw an image on to the screen. My image is drawn correctly but the background color which is transparent is shown black.
Why is this so?
My Code:
spriteBatch.Draw(Texture, Position + origin, SourceRect, Color.White * Alpha, 0.0f, origin, Scale, SpriteEffects.None, 0.0f);
Upvotes: 0
Views: 360
Reputation: 205
Have a look at the Begin method of the SpriteBatch class: https://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritebatch.begin.aspx
It is possible you set the BlendState to something that would ignore the alpha value of the texture.
To check if the Content Processor correctly imports the alpha values of your texture, try to run this code, the pixel at 0, 0 being a transparent pixel:
Color[] tData = null;
texture.GetData<Color>(tData);
Debug.Print(tData[0].ToString());
texture being the Texture2D you loaded from a ContentManager.
Upvotes: 1