Hi Verena,
Hello NG,
i want to take a screenshot of my device and save it as jpg-file. i
want to do this in vb.net (2008) and compactframework 3.5 . i dont
want to use external tools.
the device is motorola mc5590.
Maybe someone has an example for me?
it is really simple. It is just one P/Invoke command, the rest is plain
..Net.
You just need to invoke the "BitBlt"-function from "coredll.dll".
[DllImport("coredll.dll")]
public static extern bool BitBlt(IntPtr hdc, int nXDest, int nYDest, int
nWidth, int nHeight, IntPtr hdcSrc, int nXsrc, int dwRop);
public static function Bitmap GetSnapshot(Control control)
{
//checking control
if (control == null)
{
//exit
return null;
}
//create a graphics object for control
Graphics cgraphics = control.CreateGraphics();
//create a bitmap of controls' size
Bitmap snapshot = new Bitmap(control.Size.Width, control.Size.Height);
//create a graphics object for snapshot
Graphics sgraphics = Graphics.FromImage(snapshot);
//make snapshot from control
BitBlt(sgraphics.GetHDC(), 0, 0, snapshot.Size.Width, snapshot.Size.Height,
cgraphics.GetHdc(), 0 - control.Location.Left, 0 - control.Location.Top,
0XCC0020);
//disposing the graphics objects
cgraphics.Dispose();
sgraphics.Dispose();
//set return value
return snapshot;
}
Fell free to ask, if you might have any questions.
Regards,
Carsten Unterberg | Test-Framework
http://test-framework.blogspot.com/
BitBlt(