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】自己写一个截图软件--像素复制
猜你喜欢
转载自blog.csdn.net/zoysia1314/article/details/86569451
今日推荐
周排行