Skip to main content
Commonmark migration
Source Link

#PowerShell#

PowerShell

#PowerShell#

PowerShell

typos
Source Link
Rynant
  • 2.4k
  • 15
  • 19

#Powershell##PowerShell#

Write '42' to a bitmap, then use the pixel data to write asciiASCII art '42'

#Powershell#

Write '42' to a bitmap, then use the pixel data to write ascii art '42'

#PowerShell#

Write '42' to a bitmap, then use the pixel data to write ASCII art '42'

shortened last write-host
Source Link
Rynant
  • 2.4k
  • 15
  • 19
$null = [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
$bmp = New-Object System.Drawing.Bitmap(24, 20)
$font = New-Object Drawing.Font 'Courier Regular',20,0,2
$graphic = [drawing.graphics]::FromImage($bmp)
$graphic.DrawString(42, $font,[drawing.brushes]::White, 0, 0)

$rect = new-object drawing.Rectangle (0, 0, $bmp.Width, $bmp.Height)
[Drawing.Imaging.BitmapData]$bd = $bmp.LockBits($rect,
        [Drawing.Imaging.ImageLockMode]::ReadOnly, 
        [Drawing.Imaging.PixelFormat]::Format1bppIndexed)

$bp = New-Object Drawing.Bitmap (24, 20, $bd.Stride, 
        [Drawing.Imaging.PixelFormat]::Format1bppIndexed, 
        $bd.Scan0)

foreach($y in 0..19) {
    foreach($x in 0..23) {
        if($bp.GetPixel($x, $y).r) { $p = '42' }
        else { $p = '  ' }
        Write-Host $p -NoNewline
    }
    Write-Host "`n" -NoNewline
}
$null = [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
$bmp = New-Object System.Drawing.Bitmap(24, 20)
$font = New-Object Drawing.Font 'Courier Regular',20,0,2
$graphic = [drawing.graphics]::FromImage($bmp)
$graphic.DrawString(42, $font,[drawing.brushes]::White, 0, 0)

$rect = new-object drawing.Rectangle (0, 0, $bmp.Width, $bmp.Height)
[Drawing.Imaging.BitmapData]$bd = $bmp.LockBits($rect,
        [Drawing.Imaging.ImageLockMode]::ReadOnly, 
        [Drawing.Imaging.PixelFormat]::Format1bppIndexed)

$bp = New-Object Drawing.Bitmap (24, 20, $bd.Stride, 
        [Drawing.Imaging.PixelFormat]::Format1bppIndexed, 
        $bd.Scan0)

foreach($y in 0..19) {
    foreach($x in 0..23) {
        if($bp.GetPixel($x, $y).r) { $p = '42' }
        else { $p = '  ' }
        Write-Host $p -NoNewline
    }
    Write-Host "`n" -NoNewline
}
$null = [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
$bmp = New-Object System.Drawing.Bitmap(24, 20)
$font = New-Object Drawing.Font 'Courier Regular',20,0,2
$graphic = [drawing.graphics]::FromImage($bmp)
$graphic.DrawString(42, $font,[drawing.brushes]::White, 0, 0)

$rect = new-object drawing.Rectangle (0, 0, $bmp.Width, $bmp.Height)
[Drawing.Imaging.BitmapData]$bd = $bmp.LockBits($rect,
        [Drawing.Imaging.ImageLockMode]::ReadOnly, 
        [Drawing.Imaging.PixelFormat]::Format1bppIndexed)

$bp = New-Object Drawing.Bitmap (24, 20, $bd.Stride, 
        [Drawing.Imaging.PixelFormat]::Format1bppIndexed, 
        $bd.Scan0)

foreach($y in 0..19) {
    foreach($x in 0..23) {
        if($bp.GetPixel($x, $y).r) { $p = '42' }
        else { $p = '  ' }
        Write-Host $p -NoNewline
    }
    Write-Host
}
Source Link
Rynant
  • 2.4k
  • 15
  • 19
Loading