c#system.drawing.drawimage()在错误的地方绘制位图

发布于 2025-02-04 10:08:55 字数 594 浏览 1 评论 0原文

我有一个面板控件和大小相同的位图。调整面板大小时,我希望在其上绘制位图。我使用drawimage(Image,int32,int32,int32,int32)

这是面板(帆布)涂料事件

private void Canvas_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.DrawImage(image, 0, 0, Canvas.Width, Canvas.Height);
        }

,但图像有点移动。看起来该方法将其绘制在(-0.5,-0.5)中,而不是(0,0)

原始图片< /a>

上的位图(剪切了红色像素和深灰色边框)

bitmap on面板 它?

I have a panel control and a bitmap with the same size. When I resize the panel I want the bitmap to be drawn on it. I use DrawImage(Image, Int32, Int32, Int32, Int32)

This is the panel (Canvas) Paint Event

private void Canvas_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.DrawImage(image, 0, 0, Canvas.Width, Canvas.Height);
        }

But the image moves a bit. Looks like the method draws it in (-0.5, -0.5) instead of (0, 0)

Original picture

Bitmap on panel (Red pixel is cut and dark grey border appears)

How to fix it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文