I'm trying to implement a feature that can capture the color of a pixel in cef, but when I hook onto the render widget Chrome_RenderWidgetHostHWND and run this:
- Code: Select all
static public System.Drawing.Color GetPixelColor(IntPtr hwnd, int x, int y)
{
IntPtr hdc = GetDC(hwnd);
uint pixel = GetPixel(hdc, x, y);
System.Drawing.Color color = System.Drawing.Color.FromArgb(
(Byte)(pixel),
(Byte)(pixel >> 8),
(Byte)(pixel >> 16));
ReleaseDC(hwnd, hdc);
return color;
}
Everything within the CEF window bond is reporting 0,0,0, while everything outside of CEF window bond is 255,255,255
Same results go with Chrome_WidgetWin_0 or CefBrowserWindow handles.
So far the only successful handle of getting pixel color has been WindowsForms10.Window.8.app.0.3d7e188_r6_ad1.
But that simply returns the desktop pixel color instead of color of the specific CEF handle.
So if CEF is covered, the code would report the covering pixel's color than CEF's pixel color.
This is the CEF app I'm working off with: https://github.com/dghkd/FlowerMaster
This is the xaml implementation:
- Code: Select all
<cefSharp:ChromiumWebBrowser x:Name="mainWeb"
Width="1145"
Height="650"
Margin="0,0,0,0"
AllowDrop="False"
FrameLoadEnd="mainWeb_FrameLoadEnd"
IsBrowserInitializedChanged="mainWeb_IsBrowserInitializedChanged">
</cefSharp:ChromiumWebBrowser>
This is the initialization:
- Code: Select all
public static void CefInitialize()
{
if (CefCachePath == null
|| CefCachePath == "")
{
CefCachePath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"FlowerMaster",
"Chromium");
}
var cefSettings = new CefSettings()
{
CachePath = CefCachePath
};
cefSettings.CefCommandLineArgs.Add("proxy-server", GetLocalProxySettingString());
CefSharpSettings.SubprocessExitIfParentProcessClosed = true;
Cef.EnableHighDPISupport();
Cef.Initialize(cefSettings);
}
I am not completely familiar with CEF, so please let me know if more information is required.
What I am looking for:
A way to get pixel color of CEF, even when the CEF window is covered by another application
Any ideas are appreciated, an alternate way of getting color, another CEF implementation, or some CEF fumbling that can get it working would all help with this!
Thank you,
David.