# 生成 desktop/Assets/app.ico(256×256,PNG 压缩的 ICO) # 用法:powershell -ExecutionPolicy Bypass -File desktop/tools/make-icon.ps1 Add-Type -AssemblyName System.Drawing $out = Join-Path $PSScriptRoot '..\Assets\app.ico' $out = [System.IO.Path]::GetFullPath($out) New-Item -ItemType Directory -Force -Path (Split-Path $out) | Out-Null $size = 256 $bmp = New-Object System.Drawing.Bitmap $size, $size $g = [System.Drawing.Graphics]::FromImage($bmp) $g.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::AntiAlias $g.Clear([System.Drawing.Color]::Transparent) # 品牌蓝底 + 白色播放三角("视频溯源") $bg = New-Object System.Drawing.SolidBrush ([System.Drawing.Color]::FromArgb(255, 37, 99, 235)) $g.FillRectangle($bg, 12, 12, 232, 232) $play = New-Object System.Drawing.SolidBrush ([System.Drawing.Color]::White) $points = @( (New-Object System.Drawing.Point 100, 74), (New-Object System.Drawing.Point 100, 182), (New-Object System.Drawing.Point 186, 128) ) $g.FillPolygon($play, $points) $bg.Dispose() $play.Dispose() $g.Dispose() $stream = New-Object System.IO.MemoryStream $bmp.Save($stream, [System.Drawing.Imaging.ImageFormat]::Png) $png = $stream.ToArray() $stream.Dispose() $bmp.Dispose() # ICO 头(22 字节)+ PNG 数据(Vista 起支持 PNG 压缩的 ICO) $file = [System.IO.File]::Create($out) $writer = New-Object System.IO.BinaryWriter($file) $writer.Write([UInt16]0) # reserved $writer.Write([UInt16]1) # type: icon $writer.Write([UInt16]1) # count $writer.Write([Byte]0) # width 256 -> 0 $writer.Write([Byte]0) # height 256 -> 0 $writer.Write([Byte]0) # palette $writer.Write([Byte]1) # reserved $writer.Write([UInt16]1) # color planes $writer.Write([UInt16]32) # bpp $writer.Write([UInt32]$png.Length) # size $writer.Write([UInt32]22) # offset $writer.Write($png) $writer.Flush() $writer.Dispose() $file.Dispose() Write-Host "已生成: $out ($([System.IO.File]::ReadAllBytes($out).Length) 字节)"