Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27153

VS 2010 Desktop Screen to HDC

$
0
0
Ok, so I'm getting the color of a pixel on my desktop with this code:

Code:

Private Function GetScreenPixel(ByVal PT As Point) As Color
        Dim Pixel As Bitmap = New Bitmap(1, 1)
        Dim GFX As Graphics = Graphics.FromImage(Pixel)
        GFX.CopyFromScreen(PT, Point.Empty, New Size(1, 1))
        Dim BMD As BitmapData = Pixel.LockBits(New Rectangle(0, 0, 1, 1), ImageLockMode.ReadOnly, PixelFormat.Format32bppRgb)
        Dim ARGB As Int32 = Marshal.ReadInt32(BMD.Scan0, 0)
    End Function

Is it possible to get the pixel from an hDC/hWnd instead? Like doing this first:

Code:

Dim hWnD As IntPtr = FindWindow(vbnullstring,"Window Title")
I think the code's right, I can't open VS right now, so I typed it from memory. :)

Viewing all articles
Browse latest Browse all 27153

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>