Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何检测图形是否会抖动?_C#_.net_Winforms_Graphics - Fatal编程技术网

C# 如何检测图形是否会抖动?

C# 如何检测图形是否会抖动?,c#,.net,winforms,graphics,C#,.net,Winforms,Graphics,我们的应用程序在缩略图下绘制阴影。它通过创建位图,使用Graphics.FromImage获取Graphics对象,然后使用Graphics.DrawImage覆盖图像来实现。我今天第一次在远程桌面上使用它,它看起来很糟糕,因为阴影正在抖动。我不知道这是在覆盖过程中发生的,还是在RDP客户机中发生的。是否有办法通过查看图像、图形对象或屏幕设置来确定最终图像是否会抖动,以便我可以忽略阴影?您可以使用System.Windows.Forms.SystemInformation.TerminalSer

我们的应用程序在缩略图下绘制阴影。它通过创建位图,使用
Graphics.FromImage
获取
Graphics
对象,然后使用
Graphics.DrawImage
覆盖图像来实现。我今天第一次在远程桌面上使用它,它看起来很糟糕,因为阴影正在抖动。我不知道这是在覆盖过程中发生的,还是在RDP客户机中发生的。是否有办法通过查看图像、图形对象或屏幕设置来确定最终图像是否会抖动,以便我可以忽略阴影?

您可以使用System.Windows.Forms.SystemInformation.TerminalServerSession变量来检测您是否处于RDP模式并相应降级

我不知道如何检测RDP客户端是否抖动,或者deskto的颜色深度是否改变以匹配它,但您可以通过以下功能检测后者:

using System.Runtime.InteropServices;

public class DeviceCaps
{
    private const int PLANES = 14;
    private const int BITSPIXEL = 12;
    [DllImport("gdi32", CharSet = CharSet.Ansi, 
        SetLastError = true, ExactSpelling = true)]
    private static extern int GetDeviceCaps(int hdc, int nIndex);
    [DllImport("user32", CharSet = CharSet.Ansi, 
        SetLastError = true, ExactSpelling = true)]
    private static extern int GetDC(int hWnd);
    [DllImport("user32", CharSet = CharSet.Ansi, 
        SetLastError = true, ExactSpelling = true)]
    private static extern int ReleaseDC(int hWnd, int hdc);
    
    public short ColorDepth()
    {
        int dc = 0;
        try 
        {
            dc = GetDC(0);
            var nPlanes = GetDeviceCaps(dc, PLANES);
            var bitsPerPixel = GetDeviceCaps(dc, BITSPIXEL);
            return nPlanes * bitsPerPixel;                 
        }
        finally
        {
            if (dc != 0)
                ReleaseDC(0, dc);
        }
    }
}

基于颜色深度的渲染比推测性降级更可取,假设用户是因为RDP而这样做的,但对您来说可能已经足够了。

您可以使用System.Windows.Forms.SystemInformation.TerminalServerSession变量来检测您是否处于RDP模式并相应降级

我不知道如何检测RDP客户端是否抖动,或者deskto的颜色深度是否改变以匹配它,但您可以通过以下功能检测后者:

using System.Runtime.InteropServices;

public class DeviceCaps
{
    private const int PLANES = 14;
    private const int BITSPIXEL = 12;
    [DllImport("gdi32", CharSet = CharSet.Ansi, 
        SetLastError = true, ExactSpelling = true)]
    private static extern int GetDeviceCaps(int hdc, int nIndex);
    [DllImport("user32", CharSet = CharSet.Ansi, 
        SetLastError = true, ExactSpelling = true)]
    private static extern int GetDC(int hWnd);
    [DllImport("user32", CharSet = CharSet.Ansi, 
        SetLastError = true, ExactSpelling = true)]
    private static extern int ReleaseDC(int hWnd, int hdc);
    
    public short ColorDepth()
    {
        int dc = 0;
        try 
        {
            dc = GetDC(0);
            var nPlanes = GetDeviceCaps(dc, PLANES);
            var bitsPerPixel = GetDeviceCaps(dc, BITSPIXEL);
            return nPlanes * bitsPerPixel;                 
        }
        finally
        {
            if (dc != 0)
                ReleaseDC(0, dc);
        }
    }
}
基于颜色深度的渲染比假设用户是因为RDP而进行的推测性降级更可取,但对您来说可能已经足够了