mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-04-25 22:29:47 +08:00
refactor: use Fischless
This commit is contained in:
14
Fischless.WindowCapture/BitmapExtensions.cs
Normal file
14
Fischless.WindowCapture/BitmapExtensions.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user