public class ImageUtil
{
public static Bitmap GetBitmapFromImage(Bitmap source,Rectangle selectRectangle)
{
Bitmap bm = new Bitmap(selectRectangle.Size.Width, selectRectangle.Size.Height);
for (int i = 0; i < selectRectangle.Width; i++)
{
for (int j = 0; j < selectRectangle.Height; j++)
{
var p = source.GetPixel(selectRectangle.Location.X + i, selectRectangle.Location.Y + j);
bm.SetPixel(i, j, p);
}
}
return bm;
}
public static Bitmap GetBitmapFromImage(Image imgSource, Rectangle selectRectangle)
{
Bitmap source = imgSource as Bitmap;
if(source==null) return null;
return GetBitmapFromImage(source, selectRectangle);
}
}
【WinForm】自己写一个截图软件3 --像素复制
最新推荐文章于 2019-01-21 10:44:58 发布