我正在使用屏幕共享项目.我正在使用以下功能捕获桌面屏幕.它工作正常.但是每当安全桌面提示提升时,都会返回黑/空图像.
但是,当我从本地安全策略关闭安全桌面时.它工作正常.
有没有办法捕获安全桌面而不禁用本地安全策略.
static Bitmap CaptureDesktop()
{
SIZE size;
Bitmap printscreen = null;
size.cx = Win32Stuff.GetSystemMetrics
(Win32Stuff.SM_CXSCREEN);
size.cy = Win32Stuff.GetSystemMetrics
(Win32Stuff.SM_CYSCREEN);
int width = size.cx; int height = size.cy;
IntPtr hWnd = Win32Stuff.GetDesktopWindow();
IntPtr hDC = Win32Stuff.GetDC(hWnd);
if (hDC != IntPtr.Zero)
{
IntPtr hMemDC = GDIStuff.CreateCompatibleDC(hDC);
if (hMemDC != IntPtr.Zero)
{
IntPtr m_HBitmap = GDIStuff.CreateCompatibleBitmap(hDC, width, height);
if (m_HBitmap != IntPtr.Zero)
{
IntPtr hOld = (IntPtr)GDIStuff.SelectObject(hMemDC, m_HBitmap);
GDIStuff.BitBlt(hMemDC, 0, 0, width, height, hDC, 0, 0, GDIStuff.SRCCOPY); …Run Code Online (Sandbox Code Playgroud) 嗨,我有一个名为 Activity 的类,
在表单上,我将其对象数组创建为,
Activity[] _actList;
Run Code Online (Sandbox Code Playgroud)
然后这样做,
List<Activity> termsList = _actList.ToList<Activity>();
Run Code Online (Sandbox Code Playgroud)
因为它_actiList是空的,所以它抛出ArgumentNullException.
所以我的问题是,
我该如何处理这个异常?
或者是否有解决方法来获得相同的功能?
请帮忙!
我是位图的新手,每像素使用 16 位Format16bppRgb555;
我想从位图数据中提取 RGB 值。这是我的代码
static void Main(string[] args)
{
BitmapRGBValues();
Console.ReadKey();
}
static unsafe void BitmapRGBValues()
{
Bitmap cur = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format16bppRgb555);
//Capture Screen
var screenBounds = Screen.PrimaryScreen.Bounds;
using (var gfxScreenshot = Graphics.FromImage(cur))
{
gfxScreenshot.CopyFromScreen(screenBounds.X, screenBounds.Y, 0, 0, screenBounds.Size, CopyPixelOperation.SourceCopy);
}
var curBitmapData = cur.LockBits(new Rectangle(0, 0, cur.Width, cur.Height),
ImageLockMode.ReadWrite, PixelFormat.Format16bppRgb555);
try
{
byte* scan0 = (byte*)curBitmapData.Scan0.ToPointer();
for (int y = 0; y < cur.Height; ++y)
{
ulong* curRow = (ulong*)(scan0 + curBitmapData.Stride * …Run Code Online (Sandbox Code Playgroud)