这是我的代码。看起来DrawIcon
忽略了缩放变换,但没有忽略平移变换。这是有特殊原因还是只是一个 bug?
protected override void OnPaint(PaintEventArgs e)
{
Icon icon = SystemIcons.Warning;
Image img = icon.ToBitmap();
// DrawIcon ignores this transform, but not a translate transform
e.Graphics.ScaleTransform(1.5f, 1.5f);
e.Graphics.DrawRectangle(Pens.Red, 60, 90, icon.Width, icon.Height);
e.Graphics.DrawString("Icon", this.Font, Brushes.Black, 100, 100);
e.Graphics.DrawIcon(icon, 60, 90);
e.Graphics.DrawRectangle(Pens.Red, 60, 190, img.Width, img.Height);
e.Graphics.DrawString("Bitmap", this.Font, Brushes.Black, 100, 200);
e.Graphics.DrawImage(img, 60, 190);
}