• EnglishSpanishGermanFrenchPolishChinese (Traditional)


EnglishSpanishGermanFrenchPolishChinese (Traditional)

Operating systems, scripting, PowerShell and security

Operating systems, software development, scripting, PowerShell tips, network and security

Menú principal
  • Categorías
  • Cursos
  • Libro de PowerShell
  • Lo mejor
  • Lo último
  • Proyectos
  • Contactar
Ir al contenido

Convert bitmap to characters in Write-Host (blue and white)

PowerShell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
$Cave = [System.Drawing.Bitmap]::FromFile( '.\juan2.jpg' )
$cave
$i=0
$a=0
$array = @()
 
for ($y = 0;$y -lt $Cave.Height;$y+=1)
{
    for ($x = 0;$x -lt $Cave.Width;$x+=1)
    {
        $col=$Cave.GetPixel($x,$y).Name
        if ($i -lt $Cave.Width -1)
        {
            switch ($col)
            {
                "ff000000" {
                    Write-Host "X" -BackgroundColor Black -ForegroundColor White -NoNewLine
                    $array += "X"
                }
            default{
                Write-Host " " -BackgroundColor white -NoNewLine
                $array += " "
                }
            }
            $i=$i+1
            if ($a -lt 9){$a=$a+1}
            else{$a=0}
        }
        else
        {
            Write-Host " "
            $array += "*"
            $i=0
            $a=0
        }
    }
}
 
#########
#Negative
#########
$uu=""
foreach ($p in $array)
{
    if ($p -eq "*")
    {
        write-Host $p -BackgroundColor Black -ForegroundColor White
        $uu=$uu+"`n"
    }
    else
    {
        write-Host $p -BackgroundColor Black -ForegroundColor White -NoNewLine
        $uu=$uu+$p
    }
}
 
###############
#Blue and white
###############
rm .\traducir2.txt
$ji=0
foreach ($pp in $uu)
{
    if($pp -match "x")
    {
        write-host $ji $pp
        $pp >> traducir2.txt
        $ji=$ji+1
        $valorfinal=$pp.Length
    }
}

Publicado el día 21 de enero de 2018

CATEGORÍAS

Automatización, Gráficos, PowerShell

ETIQUETAS

BackgroundColor, Drawing, foreach, ForegroundColor, GetPixel, Jesús Niño Camazón, Length, match, switch, System.Drawing, System.Drawing.Bitmap, Write-Host

MÁS

  • Crear una aplicación mediante en PowerShell que incremente y disminuya la frecuencia de sonido
  • Crear formulario dentro de otro formulario mediante una función con PowerShell
  • Ejercicios de PowerShell: repaso del bucle foreach y de ficheros
  • Ejercicios de PowerShell: ejercicios básicos sobre el sistema de archivos en PowerShell
  • Automatizar el funcionamiento de una aplicación que simula un piano (pulsar automáticamente las notas del piano)
  • Escribir y un mensaje en una caja de texto y hacer click en un botón de un formulario de PowerShell de forma automática utilizando SendMessage y FindWindowEx de user32.dll