mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-03-31 10:29:52 +08:00
15 lines
510 B
C#
15 lines
510 B
C#
namespace Fischless.WindowCapture;
|
|
|
|
internal static class BitmapExtensions
|
|
{
|
|
public static Bitmap Crop(this Bitmap src, int x, int y, int width, int height)
|
|
{
|
|
Rectangle cropRect = new(x, y, width, height);
|
|
Bitmap target = new(cropRect.Width, cropRect.Height);
|
|
|
|
using System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(target);
|
|
g.DrawImage(src, new Rectangle(0, 0, target.Width, target.Height), cropRect, GraphicsUnit.Pixel);
|
|
return target;
|
|
}
|
|
}
|