jac*_*nad 10 c# drawstring picturebox winforms
我正在尝试为彩色图像添加文本比例.agcScale.jpg图像(下方)是顶部和底部的2个winform标签,左侧和右侧是2个winform图片框.完全相同的代码用于在右侧和左侧图片框中生成字符串,唯一的区别是pictureBoxAgcVscale仅包含字符串.为什么pictureBoxAgc中的DrawString看起来不错,但pictureBoxAgcVscale中的DrawString看起来如此糟糕?我可以通过为每个像素执行bmp.SetPixel来修复pictureBoxAgcVscale,但这似乎是解决此问题的错误方法.

private void DisplayAgcVscale(double min, double max)
{
var bmp = new Bitmap(pictureBoxAgcVscale.Width, pictureBoxAgcVscale.Height);
var c = (max - min) / bmp.Height;
using (var g = Graphics.FromImage(bmp))
{
var font = new Font("Microsoft Sans Serif", 8.25F);
var y1 = bmp.Height / 10;
for (var y = y1; y < bmp.Height; y += y1)
{
var agc = y * c + min;
var text = agc.ToString("#0.000V");
var h = bmp.Height - y - font.Height / 2;
g.DrawString(text, font, Brushes.Black, 0, h);
}
}
pictureBoxAgcVscale.Image = bmp;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4053 次 |
| 最近记录: |