Is there a way to take a screenshot of the current UI (4.3" 480x272).
My attempt:
var Screen = Graphics.FromHdc(Display.DisplayController.Hdc);
byte[] bmp = Screen.GetBitmap(0, 0, 480, 272);
var bm = new Bitmap(bmp, 480, 272);
using (var FileHandle = new FileStream(fi.FullName, FileMode.Create))
{
bm.Save(FileHandle, System.Drawing.Imaging.ImageFormat.Bmp);
etc.
You need to call this somewhere before start UI, probably in main().
Graphics.OnFlushEvent += Graphics_OnFlushEvent;
Then every time UI flush to screen , it will trigger function Graphics_OnFlushEvent, then you take data, convert to bitmap and save to bmp format.
Example below:
private static void Graphics_OnFlushEvent(Graphics sender, byte[] data, int x, int y, int width, int height, int originalWidth)
{
Debug.WriteLine("count flush " + count++);
var bmpBitmap = new Bitmap(data, width, height);
var sdController = StorageController.FromName(SC20260.StorageController.SdCard);
var provider = FileSystem.Mount(sdController.Hdc);
var stream = new FileStream(@"A:\UICapture.bmp", FileMode.CreateNew);
bmpBitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);
stream.Close();
FileSystem.Flush(sdController.Hdc);
FileSystem.Unmount(sdController.Hdc);
}