wapnomad.blogg.se

Windows color dropper app
Windows color dropper app






windows color dropper app

SourceDC = InteropHelper.GetDC(InteropHelper.GetDesktopWindow()) gets the main desktop and all open windows IntPtr compatibleBitmapHandle = IntPtr.Zero

#Windows color dropper app code#

Since we going to take snap shot of the entire screen, get Width and Height of the screen using the static class SystemParameters.Ĭopy Code public static BitmapSource CaptureRegion( IntPtr hWnd, int x, int y, int width, int height) The screen capture method will get parameters like X, Y, Width and height parameters. Using these Interop Helpers take a screen shot of your desktop. Public static extern int ReleaseDC( IntPtr hwnd, IntPtr dc) Public static extern bool DeleteObject( IntPtr hObject) Public static extern IntPtr SelectObject( IntPtr hdc, IntPtr hgdiobj) Public static extern IntPtr CreateCompatibleDC( IntPtr hdc) Public static extern IntPtr CreateCompatibleBitmap( IntPtr hdc, int nWidth, int nHeight)

windows color dropper app

Public static extern bool BitBlt( IntPtr hDestDC, int x, int y, int nWidth, int nHeight, IntPtr hSrcDC, int xSrc, int ySrc, Int32 dwRop) Public static extern IntPtr GetDC( IntPtr hwnd)

windows color dropper app

Public static extern IntPtr GetDesktopWindow() We need few methods from User32.dll and gdi32.dll. But in WPF, we need to call pinvoke methods to do that. Lets start with capturing the screen shot,Ĭapturing the screenshot is pretty easy with Windows Forms. For every mouse move we going to pick the appropriate pixel information from the image. The base idea is to pick color from the screen wherever the mouse moving. The underlying magic behind the implementation is, need to take a snap shot of the entire desktop. But the control I posted here will helps you to choose color from anywhere even outside your application like the one in Expression Blend or Visual Studio Designer. We can move the mouse over the desktop and other applications to pick the color under the mouse. A normal eye dropper will pick color only within the application like the one in Adobe Illustrator or Photoshop. Usually we come across different types of eye dropper controls in designers.








Windows color dropper app