本文介绍了910122-DrawImage问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨以下代码中两个矩形之间的间距是多少?void f5(图形g) { var img = Bitmap.FromFile( @" d:\ small2.png"); var destRect = 新矩形( 0 , 0 , 132 , 60 ); var srcRect = 新矩形( 0 , 0 , 60 , 60 ); g.DrawImage(img,destRect,srcRect,GraphicsUnit.Pixel); destRect.X + = destRect.Width; g.DrawImage(img,destRect,srcRect,GraphicsUnit.Pixel); } 私有 无效 pictureBox1_Paint(对象发件人,PaintEventArgs e) { f5(e.Graphics); }
d:\ small2.jpg是一个60x60黑色的盒子.
查看结果:
http://www.uploadup.com/di-YN9F.png [ ^ ]
显微镜下的缝隙:
http://www.uploadup.com/di-VJA4.png [ ^ ]
解决方案
hiwhat''s the gap between two rectangles in the following code?
void f5(Graphics g) { var img = Bitmap.FromFile(@"d:\small2.png"); var destRect = new Rectangle(0, 0, 132, 60); var srcRect = new Rectangle(0, 0, 60, 60); g.DrawImage(img, destRect, srcRect, GraphicsUnit.Pixel); destRect.X += destRect.Width; g.DrawImage(img, destRect, srcRect, GraphicsUnit.Pixel); } private void pictureBox1_Paint(object sender, PaintEventArgs e) { f5(e.Graphics); }
d:\small2.jpg is a black 60x60 box.
see the result:
http://www.uploadup.com/di-YN9F.png[^]
the gap under the microscope:
http://www.uploadup.com/di-VJA4.png[^]
解决方案
这篇关于910122-DrawImage问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!