Re: GDI/Screen capture
From: Steve Bugden (SteveBugden_at_discussions.microsoft.com)
Date: 10/07/04
- Next message: Al: "tiff compression - again"
- Previous message: Magic Gooddy: "Re: drawstring and timer"
- In reply to: Justin Rogers: "Re: GDI/Screen capture"
- Next in thread: Justin Rogers: "Re: GDI/Screen capture"
- Reply: Justin Rogers: "Re: GDI/Screen capture"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 7 Oct 2004 02:47:02 -0700
Hello Justin,
Thank you for the response.
Is there a better way to do this now? I'm using Visual Studio 2002.
Regards,
Steve.
"Justin Rogers" wrote:
> Whidbey introduces a CopyFromScreen method on the Graphics class. This will
> be used to promote bits on the Desktop DC into a managed environment. There
> were also GDI wrappers that had been written, but they are apparently marked
> internal in the latest releases and only available to the Windows Forms guys.
>
>
> --
> Justin Rogers
> DigiTec Web Consultants, LLC.
> Blog: http://weblogs.asp.net/justin_rogers
>
> "Steve Bugden" <SteveBugden@discussions.microsoft.com> wrote in message
> news:1754B3FC-C030-48A8-AD1B-42418E081C6A@microsoft.com...
> > Hi All
> >
> > Sometime ago I found some code which captures the screen using GDI (attached).
> >
> > I am wondering if it is posssible to achieve this directly from .Net without
> > the API calls. If this isn't possible is there a better way to do it.
> >
> > What sort of deployment issues will I have with the code attached below.
> > Will I need to deploy the gdi32.dll with my application for example?
> >
> > Regards,
> >
> > Steve.
> >
> > Public Class clsScreenCapture
> >
> > Private Declare Function CreateDC Lib "gdi32" Alias "CreateDCA" (ByVal
> > lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As
> > String, ByVal lpInitData As String) As Integer
> > Private Declare Function CreateCompatibleDC Lib "GDI32" (ByVal hDC As
> > Integer) As Integer
> > Private Declare Function CreateCompatibleBitmap Lib "GDI32" (ByVal hDC As
> > Integer, ByVal nWidth As Integer, ByVal nHeight As Integer) As Integer
> > Private Declare Function GetDeviceCaps Lib "gdi32" Alias "GetDeviceCaps"
> > (ByVal hdc As Integer, ByVal nIndex As Integer) As Integer
> > Private Declare Function SelectObject Lib "GDI32" (ByVal hDC As Integer,
> > ByVal hObject As Integer) As Integer
> > Private Declare Function BitBlt Lib "GDI32" (ByVal srchDC As Integer, ByVal
> > srcX As Integer, ByVal srcY As Integer, ByVal srcW As Integer, ByVal srcH As
> > Integer, ByVal desthDC As Integer, ByVal destX As Integer, ByVal destY As
> > Integer, ByVal op As Integer) As Integer
> > Private Declare Function DeleteDC Lib "GDI32" (ByVal hDC As Integer) As
> > Integer
> > Private Declare Function DeleteObject Lib "GDI32" (ByVal hObj As Integer)
> > As Integer
> > Const SRCCOPY As Integer = &HCC0020
> >
> > Public Function CaptureScreen() As Bitmap
> >
> > Dim hSDC, hMDC As Integer
> > Dim hBMP, hBMPOld As Integer
> > Dim r As Integer
> > Dim oBackground As Bitmap
> >
> > hSDC = CreateDC("DISPLAY", "", "", "")
> > hMDC = CreateCompatibleDC(hSDC)
> >
> > Dim fw, fh As Integer
> >
> > fw = Screen.PrimaryScreen.Bounds.Width 'GetDeviceCaps(hSDC, 0)
> > fh = Screen.PrimaryScreen.Bounds.Height 'GetDeviceCaps(hSDC, 10)
> > hBMP = CreateCompatibleBitmap(hSDC, fw, fh)
> >
> > hBMPOld = SelectObject(hMDC, hBMP)
> > r = BitBlt(hMDC, 0, 0, fw, fh, hSDC, 0, 0, 13369376)
> > hBMP = SelectObject(hMDC, hBMPOld)
> >
> > r = DeleteDC(hSDC)
> > r = DeleteDC(hMDC)
> >
> > Return Image.FromHbitmap(New IntPtr(hBMP))
> > DeleteObject(hBMP)
> >
> > End Function
> >
> > End Class
>
>
>
- Next message: Al: "tiff compression - again"
- Previous message: Magic Gooddy: "Re: drawstring and timer"
- In reply to: Justin Rogers: "Re: GDI/Screen capture"
- Next in thread: Justin Rogers: "Re: GDI/Screen capture"
- Reply: Justin Rogers: "Re: GDI/Screen capture"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|