$ErrorActionPreference = "Stop" Add-Type -AssemblyName System.Drawing $dir = "storage\cards" New-Item -ItemType Directory -Force -Path $dir | Out-Null New-Item -ItemType Directory -Force -Path "storage" | Out-Null $w = 240 $h = 320 $bmp = New-Object System.Drawing.Bitmap($w, $h) $g = [System.Drawing.Graphics]::FromImage($bmp) $g.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::AntiAlias # Vertical gradient: one fast FillRectangle per row for ($y = 0; $y -lt $h; $y++) { $blue = [byte]([int]((255 * $y) / ($h - 1))) $green = [byte]([int]((255 * (($y * 7) % $h)) / $h)) $red = [byte]([int]((255 * (($y * 3) % $h)) / $h)) $b = [System.Drawing.SolidBrush]::new([System.Drawing.Color]::FromArgb($red, $green, $blue)) $g.FillRectangle($b, 0, $y, $w, 1) $b.Dispose() } # Diagonal stripe for visual aliasing check $stripe = [System.Drawing.SolidBrush]::new([System.Drawing.Color]::FromArgb(255, 255, 255)) for ($x = -$h; $x -lt $w; $x += 40) { $pts = [System.Drawing.Point[]]@( [System.Drawing.Point]::new($x, 0), [System.Drawing.Point]::new($x + 20, 0), [System.Drawing.Point]::new($x + 20 + $h, $h), [System.Drawing.Point]::new($x + $h, $h) ) $g.FillPolygon($stripe, $pts) } $stripe.Dispose() $font = [System.Drawing.Font]::new([System.Drawing.FontFamily]::GenericSansSerif, 22, [System.Drawing.FontStyle]::Bold) $font2 = [System.Drawing.Font]::new([System.Drawing.FontFamily]::GenericSansSerif, 14, [System.Drawing.FontStyle]::Bold) $white = [System.Drawing.Brushes]::White $black = [System.Drawing.Brushes]::Black # Text with outline $txt1 = "MTG RFID" $txt2 = "COMPANION" $sz1 = $g.MeasureString($txt1, $font) $g.DrawString($txt1, $font, $black, 28 - 2, 40 - 2) $g.DrawString($txt1, $font, $white, 28, 40) $g.DrawString($txt2, $font, $black, 28 - 2, 40 + $sz1.Height - 2) $g.DrawString($txt2, $font, $white, 28, 40 + $sz1.Height) $g.DrawString("240x320 RGB565", $font2, $white, 28, 260) $g.DrawString("ST7789 TJPGD", $font2, $white, 28, 285) $bmp.Save("$dir\sample.jpg", [System.Drawing.Imaging.ImageFormat]::Jpeg) $g.Dispose() $bmp.Dispose() Get-Item "$dir\sample.jpg" | Select-Object FullName, Length