Files
chuzhongzai 2d85527656 实现 .NET 10 托盘版网关保活
包含分层探测、可补偿的 IPv4 路由/DNS 切换、自动策略、托盘与分组设置界面、只读诊断工具、离线测试和发布脚本。
2026-10-23 23:35:20 +08:00

22 lines
1.1 KiB
PowerShell

param([string]$Source, [string]$Target, [int]$X, [int]$Y, [int]$Width, [int]$Height, [int]$Zoom = 2)
Add-Type -AssemblyName System.Drawing
$image = [System.Drawing.Image]::FromFile((Resolve-Path -LiteralPath $Source))
try {
$crop = New-Object System.Drawing.Bitmap($Width, $Height)
$graphics = [System.Drawing.Graphics]::FromImage($crop)
try {
$graphics.DrawImage($image, (New-Object System.Drawing.Rectangle(0, 0, $Width, $Height)), $X, $Y, $Width, $Height, [System.Drawing.GraphicsUnit]::Pixel)
} finally { $graphics.Dispose() }
$factor = [int]$Zoom
$zoomWidth = [int]$Width * $factor
$zoomHeight = [int]$Height * $factor
$scaled = New-Object System.Drawing.Bitmap($zoomWidth, $zoomHeight)
$scaledGraphics = [System.Drawing.Graphics]::FromImage($scaled)
try {
$scaledGraphics.InterpolationMode = [System.Drawing.Drawing2D.InterpolationMode]::NearestNeighbor
$scaledGraphics.DrawImage($crop, 0, 0, $zoomWidth, $zoomHeight)
} finally { $scaledGraphics.Dispose() }
$scaled.Save($Target, [System.Drawing.Imaging.ImageFormat]::Png)
$scaled.Dispose(); $crop.Dispose()
} finally { $image.Dispose() }