Morning all (if its morning where you are)
I have been looking around and have not seen a satisfactory method for doing this so thought I would ask around...
Ide
You can either use a RenderTarget2D
(MSDN), which is itself a Texture2D
(so you can use it in SpriteBatch.Draw
). This allows you to render onto a texture in the same way you render onto the screen. You need to use GraphicsDevice.SetRenderTarget
(MSDN) to set this up.
Or you can use Texture2D.SetData
(MSDN) to manipulate pixels directly. You can construct a transparent Texture2D
directly (MSDN). Don't forget to Dispose
of any textures or other resources you create yourself!