![](/img/trans.png)
[英]No suitable graphics card is found error in Visual Studio 2010 debug mode
[英]Scaling graphics Visual Studio 2010
我在用C#(Visual Studio 2010)编写的程序中缩放时遇到问题。 通常,它的外观应如下图所示(图1),该图在装有Windows 7和8的大多数计算机上也可以使用。当通过“屏幕分辨率”窗口中的“使文本和其他项目变大或变小”将缩放比例更改为125%时这些图形在某些计算机上而不是在所有计算机上都有损坏(请参见图2)。
每对圆圈都是一个“用户定义的控件/组件”。 这些是从人体中抽出的,而人体是圆圈后面的图像。 下面附有一段代码。
// use high quality graphics
e.Graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
// Set the SmoothingMode property to smooth the line.
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
Pen pen = new Pen(_electrodeLineColor, 4 + 8 * ((float)value / MAX_ELECTRODE_VALUE));
// Set the DashCap to round.
pen.DashCap = System.Drawing.Drawing2D.DashCap.Round;
// if active then draw the line
if (_electrodeValue > 0)
{
e.Graphics.DrawLine(pen, _point1, _point2);
}
// indicate hovering
Console.WriteLine("Electrode " + _electrodePairNo + ", OnPaint, hover state: " + _hover.ToString());
if (_hover)
{
// draw selection circle 1
e.Graphics.FillEllipse(new SolidBrush(Color.Black), _point1.X - _r - 3, _point1.Y - _r - 3, _diam + 5, _diam + 5);
// draw selection circle 2
e.Graphics.FillEllipse(new SolidBrush(Color.Black), _point2.X - _r - 3, _point2.Y - _r - 3, _diam + 5, _diam + 5);
}
// draw electrodes
e.Graphics.FillEllipse(new SolidBrush(Color.LightGray), _point1.X - _r + 2, _point1.Y - _r + 2, 16, 16);
e.Graphics.FillEllipse(new SolidBrush(Color.LightGray), _point2.X - _r + 2, _point2.Y - _r + 2, 16, 16);
有人遇到这个问题吗? 我乐于接受各种技巧。
问候,乔纳斯
数据的来源尚不清楚,但肯定看起来是使用像素单位而不是英寸。 您使用的表单和位图都会自动重新缩放以匹配视频适配器的DPI,并在运行125%的计算机上将它们放大。 您还需要缩放数据,请使用Graphics.DpiX / Y。 一阶估算可能看起来像这样:
var scalex = (float)e.Graphics.DpiX / image.HorizontalResolution;
var scaley = (float)e.Graphics.DpiY / image.VerticalResolution;
e.Graphics.ScaleTransform(scalex, scaley);
其中“图像”是对绘制的位图的引用,在代码段中也不可见。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.