1
我们的应用程序在缩略图下方绘制阴影。它通过创建位图,使用Graphics.FromImage
获得Graphics
对象,然后使用Graphics.DrawImage
覆盖图像。我今天第一次在远程桌面上使用它,它看起来可怕,因为阴影正在抖动。我不知道这是在覆盖期间还是在RDP客户端中发生的。有没有办法让我通过查看图像,图形对象或屏幕设置来确定最终图像是否会抖动,以便我可以忽略阴影?如何检测图形是否会抖动?
我们的应用程序在缩略图下方绘制阴影。它通过创建位图,使用Graphics.FromImage
获得Graphics
对象,然后使用Graphics.DrawImage
覆盖图像。我今天第一次在远程桌面上使用它,它看起来可怕,因为阴影正在抖动。我不知道这是在覆盖期间还是在RDP客户端中发生的。有没有办法让我通过查看图像,图形对象或屏幕设置来确定最终图像是否会抖动,以便我可以忽略阴影?如何检测图形是否会抖动?
您可以使用System.Windows.Forms.SystemInformation.TerminalServerSession变量来检测您是否处于RDP模式并相应地降级。
我不知道的方式来检测RDP客户端是否不抖动或deskto的颜色深度是否被转移到与之相匹配的,但你可以通过GetDeviceCaps功能检测后者:基于
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而这样做,颜色深度优于推测性降级,但对您而言可能就足够了。