本文介绍了图片在C#中的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Bitmap ax = new Bitmap(300, 300);
Rectangle rc = new Rectangle(0, 0, 300, 300);
this.DrawToBitmap(ax, rc);
pictureBox1.Image = ax;
运行此代码后,我们得到了一部分形式的图像(从point(0,0)到point(300,300)),但是我想要从point(300,300)到point(600,600)的图像.
我该怎么做?
after running this code we have an image of part of form (from point(0,0) to point(300,300)) but i want an image from point(300,300) to point(600,600).
How I can do it?
推荐答案
Bitmap imageOfControl = new Bitmap(600, 600);
Rectangle rc = new Rectangle(0, 0, 600, 600);
this.DrawToBitmap(imageOfControl , rc);
Bitmap ax = new Bitmap(300,300);
using (Graphics g = Graphics.FromImage(ax))
{
g.DrawImage(imageOfControl, new Rectangle (300, 300, 300, 300), new Rectangle(0, 0, 300, 300), GraphicsUnit.Pixel);
}
imageOfControl.Dispose();
pictureBox1.Image = ax;
这篇关于图片在C#中的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!