Add-Type -AssemblyName PresentationCore,WindowsBase

$path = 'c:\Users\Administrator\Documents\PaaS\photobooth\src\assets\1.png'
$fs = [System.IO.File]::OpenRead($path)
$decoder = [System.Windows.Media.Imaging.BitmapDecoder]::Create(
    $fs,
    [System.Windows.Media.Imaging.BitmapCreateOptions]::None,
    [System.Windows.Media.Imaging.BitmapCacheOption]::OnLoad
)
$frame = $decoder.Frames[0]
$w = $frame.PixelWidth
$h = $frame.PixelHeight
$stride = $w * 4
$bytes = New-Object byte[] ($stride * $h)
$frame.CopyPixels($bytes, $stride, 0)
$fs.Close()

# Sample first slot to see what color it has
Write-Host "=== Sampling actual photo slot colors ==="
Write-Host "`nSlot 1 (Y=250, various X):"
$y = 250
for ($x = 100; $x -le 500; $x += 50) {
    $i = ($y * $stride) + ($x * 4)
    $b = $bytes[$i]; $g = $bytes[$i + 1]; $r = $bytes[$i + 2]
    $light = if ($r -gt 180 -and $g -gt 180 -and $b -gt 180) { "WHITE-ish" }
    elseif ($b -gt ($r + 20) -and $b -gt ($g + 20)) { "BLUE-ish" }
    else { "OTHER" }
    Write-Host "  x=$x: RGB($r, $g, $b) = $light"
}

Write-Host "`nSlot 2 (Y=700, various X):"
$y = 700
for ($x = 100; $x -le 500; $x += 50) {
    $i = ($y * $stride) + ($x * 4)
    $b = $bytes[$i]; $g = $bytes[$i + 1]; $r = $bytes[$i + 2]
    $light = if ($r -gt 180 -and $g -gt 180 -and $b -gt 180) { "WHITE-ish" }
    elseif ($b -gt ($r + 20) -and $b -gt ($g + 20)) { "BLUE-ish" }
    else { "OTHER" }
    Write-Host "  x=$x: RGB($r, $g, $b) = $light"
}

Write-Host "`nSlot 3 (Y=1250, various X):"
$y = 1250
for ($x = 100; $x -le 500; $x += 50) {
    $i = ($y * $stride) + ($x * 4)
    $b = $bytes[$i]; $g = $bytes[$i + 1]; $r = $bytes[$i + 2]
    $light = if ($r -gt 180 -and $g -gt 180 -and $b -gt 180) { "WHITE-ish" }
    elseif ($b -gt ($r + 20) -and $b -gt ($g + 20)) { "BLUE-ish" }
    else { "OTHER" }
    Write-Host "  x=$x: RGB($r, $g, $b) = $light"
}
