# Let’s Draw Pictures! / PowerShell Drawing

I discovered that it’s possible to draw any color character I wanted to the PowerShell console, so that obviously begged the question, can I draw ANY picture to the console?

Well it turns out that the answer to that question is yes, I can. So I did:

As always, questions and comments are welcome!

```'This script is provided under the Creative Commons license located
'at http://creativecommons.org/licenses/by-nc/2.5/ . It may not
'be used for commercial purposes with out the expressed written consent
'of NateRice.com#
# Use by typing:
# 	.\DrawPicture.ps1 .\picture.png
#
#	.\DrawPicture.ps1 -path C:\full\path\picture.png
#
# Date: 2019-03-12
#

param([String] [parameter(mandatory = \$true)] \$path)

[void] [System.Reflection.Assembly]::LoadWithPartialName('System.drawing')
\$BitMap = [System.Drawing.Bitmap]::FromFile((Get-Item \$path).fullname)

\$ansi_escape = [char]27

Function DrawColor{
param([decimal]\$r, [decimal]\$g, [decimal]\$b)

\$ansi_command = "\$ansi_escape[48;2;{0};{1};{2}m" -f \$r, \$g, \$b
\$text = " "
\$ansi_terminate = "\$ansi_escape[0m"
\$out = \$ansi_command + \$text + \$ansi_terminate
write-host -nonewline \$out
}

Foreach(\$y in (0..(\$BitMap.Height-1))){
Foreach(\$x in (0..(\$BitMap.Width-1))){
\$Pixel = \$BitMap.GetPixel(\$X,\$Y)
DrawColor -r \$(\$Pixel).R -g \$(\$Pixel).G -b \$(\$Pixel).B
}
Write-Host ""
}

\$BitMap.dispose()

Copyright 2019 naterice.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
```

https://github.com/natemrice/powershell-drawing