1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
protected override void LoadContent()
{
SpriteBatch spriteBatch = new SpriteBatch(GraphicsDevice);
Texture2D MonImage = Content.Load<Texture2D>("MonImage");
int width = MonImage.Width;
int height = MonImage.Height;
RenderTarget2D renderTarget = new RenderTarget2D(GraphicsDevice,
width,
height,
false,
SurfaceFormat.Color,
DepthFormat.None,
0,
RenderTargetUsage.PreserveContents);
GraphicsDevice.SetRenderTarget(renderTarget);
Rectangle DestRect = new Rectangle(0, 0, width, height);
spriteBatch.Begin();
spriteBatch.Draw(MonImage, DestRect, null, Color.White, 0, Vector2.Zero, SpriteEffects.FlipVertically, 0);
spriteBatch.End();
GraphicsDevice.SetRenderTarget(null);
using (Stream stream = File.Create("MonImageFlip.png"))
{
renderTarget.SaveAsPng(stream, width, height);
}
} |
Partager