mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-11 16:15:38 +00:00
Added screenshot capabilities on F12.
This commit is contained in:
parent
47bb81d62f
commit
49d1b68fa4
|
@ -164,9 +164,31 @@ namespace Examples.Tutorial
|
|||
PixelType.UnsignedByte, data.Scan0);
|
||||
bitmap.UnlockBits(data);
|
||||
}
|
||||
#endregion Textures
|
||||
#endregion Textures
|
||||
|
||||
Keyboard.KeyUp += KeyUp;
|
||||
}
|
||||
|
||||
|
||||
int i = 0;
|
||||
void KeyUp(OpenTK.Input.KeyboardDevice sender, OpenTK.Input.Key e)
|
||||
{
|
||||
if (e == OpenTK.Input.Key.F12)
|
||||
{
|
||||
Bitmap bmp = new Bitmap(this.Width, this.Height);
|
||||
System.Drawing.Imaging.BitmapData data =
|
||||
bmp.LockBits(new Rectangle(0, 0, this.Width, this.Height),
|
||||
System.Drawing.Imaging.ImageLockMode.WriteOnly,
|
||||
System.Drawing.Imaging.PixelFormat.Format24bppRgb);
|
||||
GL.ReadPixels(0, 0, this.Width, this.Height,
|
||||
OpenTK.Graphics.PixelFormat.Bgr,
|
||||
OpenTK.Graphics.PixelType.UnsignedByte,
|
||||
data.Scan0);
|
||||
bmp.UnlockBits(data);
|
||||
bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);
|
||||
bmp.Save("Screenshot" + (i++).ToString() + ".png", ImageFormat.Png);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnUnLoad
|
||||
|
@ -219,7 +241,7 @@ namespace Examples.Tutorial
|
|||
if (Keyboard[OpenTK.Input.Key.Escape])
|
||||
{
|
||||
this.Exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
Loading…
Reference in a new issue