如何在没有渐变的情况下绘制DrawImage

时间:2012-07-18 05:37:49

标签: c# .net

我有3张图片,想用它们画出我的应用背景 Top Binder
Center Binder
Bottom Binder

但是当我通过放大中心活页夹来绘制它时,我得到以下结果的渐变。有什么方法可以解决这个问题吗?

        g.DrawImage(Resources.Resource.RingBinderTop, new Rectangle((this.Size.Width - 49) / 2, 9, 49, 11));
        g.DrawImage(Resources.Resource.RingBinder, new Rectangle((this.Size.Width - 49) / 2, 20, 49, this.Size.Height - 33));
        g.DrawImage(Resources.Resource.RingBinderBottom, new Rectangle((this.Size.Width - 49) / 2, this.Size.Height - 20, 49, 11));

enter image description here

3 个答案:

答案 0 :(得分:0)

Graphics类在WinForms应用程序中绘制图像。它在重绘期间闪烁屏幕并且性能较差,因为它依赖于GDI。这可能是一种限制。

要获得平滑的结果,请使用支持DirectX的WPF。

答案 1 :(得分:0)

对此的解决方案是将FillRectangle与TextureBrush一起使用。

    g.DrawImage(Resources.Resource.RingBinderTop, new Rectangle((this.Size.Width - 49) / 2, 9, 49, 11));
    g.DrawImage(Resources.Resource.RingBinder, new Rectangle((this.Size.Width - 49) / 2, 20, 49, this.Size.Height - 33));
    g.FillRectangle(new TextureBrush(Resources.Resource.RingBinderBottom), new Rectangle((this.Size.Width - 49) / 2, this.Size.Height - 20, 49, 11));

答案 2 :(得分:0)

我找不到我发现这个的网站,但请尝试以下

g.InterpolationMode = InterpolationMode.NearestNeighbor;