2012-07-18 44 views
0

我有以下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

回答

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)); 
+0

不要忘记使用下面的代码纹理来开始在想要的位置。 // b.TranslateTransform(p.X,p.Y); – 2013-01-27 03:56:38

0

Graphics类绘制在一个WinForms应用程序图像。它在重绘过程​​中闪烁屏幕,性能差,因为它取决于GDI。这可能是一个限制。

为了获得平稳的结果,请使用支持DirectX的WPF。

+0

一些参考。 – 2012-07-18 06:19:20

0

我没有找到的网站,我发现这一点,但尝试如何在WPF实现将是非常有益以下

g.InterpolationMode = InterpolationMode.NearestNeighbor;