Experimenting a bit with RenderTarget2D in XNA 4 and I seem to be doing something wrong, but I cant figure out what.
Starting off with this:
SpriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null,null);
RenderTarget2D target = new RenderTarget2D(GraphicsDevice, 512,512);
GraphicsDevice.SetRenderTarget(target);
GraphicsDevice.Clear(Color.Green);
I then try to draw a planet texture that is 512x512 pixel:
SpriteBatch.Draw(RedPlanet512, new Vector2(256,256), null, Color.White, 0f, _origin, 1f, SpriteEffects.None, 1f);
Then just to clarify the problem i draw three red circle textures each 64x64 pixels.
SpriteBatch.Draw(RedCircle64, new Vector2(0, 0), Color.White);
SpriteBatch.Draw(RedCircle64, new Vector2(256, 256), Color.White);
SpriteBatch.Draw(RedCircle64, new Vector2(512, 512), Color.White);
When i try to draw this to the screen the resulting RenderTarget2D texture is compressed in a weird way, even thought the green backgrouns is the right size.. I thought it might be me drawing it incorrectly so i used
target.SaveAsPng(stream, target.Width, target.Height);
to see what the target actually looks like.. and I dont understand why it is compressed like it is.. See the attached picture.Any help would be greatly appreciated