
Screen Programm C#
#1 _Christopher_
geschrieben 23. April 2005 - 15:43

Anzeige
#2
geschrieben 23. April 2005 - 15:47
Hypersnap DX
FRAPS
#3 _Christopher_
geschrieben 23. April 2005 - 15:50

Edit by stefanra: Die Konsequenzen dieses Postings sollten klar sein.
Dieser Beitrag wurde von stefanra bearbeitet: 23. April 2005 - 15:56
#4
geschrieben 23. April 2005 - 15:53

#5
geschrieben 23. April 2005 - 16:24

Hier eine Klasse, die dich sicherlich weiterbringt. Musst sie halt an deine Bedürfnisse anpassen!
Quelle: c-sharpcorner.com
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
class GDI32
{
[DllImport("GDI32.dll")]
public static extern bool BitBlt(int hdcDest,int nXDest,int nYDest,
int nWidth,int nHeight,int hdcSrc,
int nXSrc,int nYSrc,int dwRop);
[DllImport("GDI32.dll")]
public static extern int CreateCompatibleBitmap(int hdc,int nWidth,
int nHeight);
[DllImport("GDI32.dll")]
public static extern int CreateCompatibleDC(int hdc);
[DllImport("GDI32.dll")]
public static extern bool DeleteDC(int hdc);
[DllImport("GDI32.dll")]
public static extern bool DeleteObject(int hObject);
[DllImport("GDI32.dll")]
public static extern int GetDeviceCaps(int hdc,int nIndex);
[DllImport("GDI32.dll")]
public static extern int SelectObject(int hdc,int hgdiobj);
}
class User32
{
[DllImport("User32.dll")]
public static extern int GetDesktopWindow();
[DllImport("User32.dll")]
public static extern int GetWindowDC(int hWnd);
[DllImport("User32.dll")]
public static extern int ReleaseDC(int hWnd,int hDC);
}
class Example
{
public void CaptureScreen(string fileName,ImageFormat imageFormat)
{
int hdcSrc = User32.GetWindowDC(User32.GetDesktopWindow()),
hdcDest = GDI32.CreateCompatibleDC(hdcSrc),
hBitmap = GDI32.CreateCompatibleBitmap(hdcSrc,
GDI32.GetDeviceCaps(hdcSrc,8),GDI32.GetDeviceCaps(hdcSrc,10));
GDI32.SelectObject(hdcDest,hBitmap);
GDI32.BitBlt(hdcDest,0,0,GDI32.GetDeviceCaps(hdcSrc,8),
GDI32.GetDeviceCaps(hdcSrc,10),
hdcSrc,0,0,0x00CC0020);
SaveImageAs(hBitmap,fileName,imageFormat);
Cleanup(hBitmap,hdcSrc,hdcDest);
}
private void Cleanup(int hBitmap,int hdcSrc,int hdcDest)
{
User32.ReleaseDC(User32.GetDesktopWindow(),hdcSrc);
GDI32.DeleteDC(hdcDest);
GDI32.DeleteObject(hBitmap);
}
private void SaveImageAs(int hBitmap,string fileName,ImageFormat imageFormat)
{
Bitmap image =
new Bitmap(Image.FromHbitmap(new IntPtr(hBitmap)),
Image.FromHbitmap(new IntPtr(hBitmap)).Width,
Image.FromHbitmap(new IntPtr(hBitmap)).Height);
image.Save(fileName,imageFormat);
}
}
#6 _Christopher_
geschrieben 23. April 2005 - 16:32



Dieser Beitrag wurde von Christopher bearbeitet: 23. April 2005 - 16:32
#8
geschrieben 28. April 2005 - 14:49
Zitat (constructor: 28.04.2005, 15:30)
<{POST_SNAPBACK}>
Ich hab das früher einmal ausprobiert und kann dir sagen, ja es klappt!
Dieser Beitrag wurde von Witi bearbeitet: 28. April 2005 - 14:49
#9 _Christopher_
geschrieben 28. April 2005 - 14:57
gespeichert..

Das Image muss ich dann selber mit Jpg öffnen das heist, es wird nicht automatisch in Jpg gespeichert


Dieser Beitrag wurde von Christopher bearbeitet: 28. April 2005 - 14:58