Next version, Working with working Progress bar
This commit is contained in:
79
Program.cs
79
Program.cs
@@ -35,63 +35,80 @@ namespace ConvertTo16x16
|
||||
|
||||
//C:\Users\zamk\Bilder\RickNice.jpg
|
||||
|
||||
string bildName = "RickNice.jpg";
|
||||
Console.Write("Geben sie den Bildnamen an: ");
|
||||
string bildName = Console.ReadLine();
|
||||
|
||||
Console.Write("Geben sie den Pfad an: ");
|
||||
string Pfad = Console.ReadLine();
|
||||
|
||||
//string Pfad = @"D:\Pictures16";
|
||||
//string bildName = "RickNice.jpg";
|
||||
int PixelAnzahl = 16;
|
||||
|
||||
Bitmap bmp = new Bitmap($@"D:\Pictures16\{bildName}"); //
|
||||
Bitmap bmp = new Bitmap($@"{Pfad}\{bildName}");
|
||||
Bitmap outcome = new Bitmap(PixelAnzahl, PixelAnzahl);
|
||||
int Width = bmp.Width / PixelAnzahl;
|
||||
int Height = bmp.Height / PixelAnzahl;
|
||||
|
||||
int counter = 0;
|
||||
|
||||
|
||||
for (int i = 0; i < PixelAnzahl; i++)
|
||||
Console.Write("Performing some task... ");
|
||||
using (var progress = new ProgressBar())
|
||||
{
|
||||
for (int j = 0; j < PixelAnzahl; j++)
|
||||
for (int i = 0; i < PixelAnzahl; i++)
|
||||
{
|
||||
|
||||
List<Count> Argb = new List<Count>();
|
||||
|
||||
for (int x = Width * i; x < Width * (i + 1); x++)
|
||||
for (int j = 0; j < PixelAnzahl; j++)
|
||||
{
|
||||
for (int y = Height * j; y < Height * (j + 1); y++)
|
||||
|
||||
List<Count> Argb = new List<Count>();
|
||||
|
||||
for (int x = Width * i; x < Width * (i + 1); x++)
|
||||
{
|
||||
|
||||
bool Exists = false;
|
||||
|
||||
foreach (var item in Argb)
|
||||
for (int y = Height * j; y < Height * (j + 1); y++)
|
||||
{
|
||||
if (bmp.GetPixel(x, y).ToArgb() == item.Argb) //Zu switch case umbauen
|
||||
|
||||
bool Exists = false;
|
||||
|
||||
foreach (var item in Argb)
|
||||
{
|
||||
Exists = true;
|
||||
item.Anzahl += 1;
|
||||
if (bmp.GetPixel(x, y).ToArgb() == item.Argb) //Zu switch case umbauen
|
||||
{
|
||||
Exists = true;
|
||||
item.Anzahl += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!Exists)
|
||||
{
|
||||
Argb.Add(new Count(bmp.GetPixel(x, y).ToArgb(), new Point(x, y), 1));
|
||||
if (!Exists)
|
||||
{
|
||||
Argb.Add(new Count(bmp.GetPixel(x, y).ToArgb(), new Point(x, y), 1));
|
||||
}
|
||||
counter++;
|
||||
|
||||
double report = Convert.ToDouble(counter) / Convert.ToDouble(16 * 16 * Width * Height);
|
||||
|
||||
progress.Report(report);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Count BiggestItem = new Count(0);
|
||||
|
||||
Count BiggestItem = new Count(0);
|
||||
|
||||
foreach (var item in Argb)
|
||||
{
|
||||
if (item.Anzahl > BiggestItem.Anzahl)
|
||||
foreach (var item in Argb)
|
||||
{
|
||||
BiggestItem = item;
|
||||
if (item.Anzahl > BiggestItem.Anzahl)
|
||||
{
|
||||
BiggestItem = item;
|
||||
}
|
||||
}
|
||||
|
||||
outcome.SetPixel(i, j, Color.FromArgb(BiggestItem.Argb));
|
||||
|
||||
}
|
||||
|
||||
outcome.SetPixel(i, j, Color.FromArgb(BiggestItem.Argb));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
outcome.Save($@"D:\Pictures16\16x16{bildName}");
|
||||
outcome.Save($@"{Pfad}\16x16{bildName}");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user