diff --git a/ConvertTo16x16.csproj b/ConvertTo16x16.csproj index 223769b..8447e6e 100644 --- a/ConvertTo16x16.csproj +++ b/ConvertTo16x16.csproj @@ -35,6 +35,7 @@ + diff --git a/Program.cs b/Program.cs index ce84dbd..db5e3e2 100644 --- a/Program.cs +++ b/Program.cs @@ -3,13 +3,96 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Drawing; namespace ConvertTo16x16 { + + class Count + { + public int Argb { get; set; } + public Point Position { get; set; } + public int Anzahl { get; set; } + + public Count(int Anzahl) + { + this.Anzahl = Anzahl; + } + + public Count(int Argb, Point Position, int Anzahl) + { + this.Argb = Argb; + this.Position = Position; + this.Anzahl = Anzahl; + } + + } + class Program { static void Main(string[] args) { + + //C:\Users\zamk\Bilder\RickNice.jpg + + string bildName = "RickNice.jpg"; + int PixelAnzahl = 16; + + Bitmap bmp = new Bitmap($@"D:\Pictures16\{bildName}"); // + Bitmap outcome = new Bitmap(PixelAnzahl, PixelAnzahl); + int Width = bmp.Width / PixelAnzahl; + int Height = bmp.Height / PixelAnzahl; + + + + for (int i = 0; i < PixelAnzahl; i++) + { + for (int j = 0; j < PixelAnzahl; j++) + { + + List Argb = new List(); + + for (int x = Width * i; x < Width * (i + 1); x++) + { + for (int y = Height * j; y < Height * (j + 1); y++) + { + + bool Exists = false; + + foreach (var item in Argb) + { + 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)); + } + } + } + + + Count BiggestItem = new Count(0); + + foreach (var item in Argb) + { + if (item.Anzahl > BiggestItem.Anzahl) + { + BiggestItem = item; + } + } + + outcome.SetPixel(i, j, Color.FromArgb(BiggestItem.Argb)); + + } + } + + outcome.Save($@"D:\Pictures16\16x16{bildName}"); + } } } diff --git a/bin/Debug/ConvertTo16x16.exe b/bin/Debug/ConvertTo16x16.exe new file mode 100644 index 0000000..062e255 Binary files /dev/null and b/bin/Debug/ConvertTo16x16.exe differ diff --git a/bin/Debug/ConvertTo16x16.exe.config b/bin/Debug/ConvertTo16x16.exe.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/bin/Debug/ConvertTo16x16.exe.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/bin/Debug/ConvertTo16x16.pdb b/bin/Debug/ConvertTo16x16.pdb new file mode 100644 index 0000000..090a115 Binary files /dev/null and b/bin/Debug/ConvertTo16x16.pdb differ diff --git a/obj/Debug/ConvertTo16x16.csproj.FileListAbsolute.txt b/obj/Debug/ConvertTo16x16.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..0861e7e --- /dev/null +++ b/obj/Debug/ConvertTo16x16.csproj.FileListAbsolute.txt @@ -0,0 +1,6 @@ +C:\Users\zamk\source\repos\ConvertTo16x16\bin\Debug\ConvertTo16x16.exe.config +C:\Users\zamk\source\repos\ConvertTo16x16\bin\Debug\ConvertTo16x16.exe +C:\Users\zamk\source\repos\ConvertTo16x16\bin\Debug\ConvertTo16x16.pdb +C:\Users\zamk\source\repos\ConvertTo16x16\obj\Debug\ConvertTo16x16.csprojAssemblyReference.cache +C:\Users\zamk\source\repos\ConvertTo16x16\obj\Debug\ConvertTo16x16.exe +C:\Users\zamk\source\repos\ConvertTo16x16\obj\Debug\ConvertTo16x16.pdb diff --git a/obj/Debug/ConvertTo16x16.csprojAssemblyReference.cache b/obj/Debug/ConvertTo16x16.csprojAssemblyReference.cache index 9c7cfcd..41627ca 100644 Binary files a/obj/Debug/ConvertTo16x16.csprojAssemblyReference.cache and b/obj/Debug/ConvertTo16x16.csprojAssemblyReference.cache differ diff --git a/obj/Debug/ConvertTo16x16.exe b/obj/Debug/ConvertTo16x16.exe new file mode 100644 index 0000000..062e255 Binary files /dev/null and b/obj/Debug/ConvertTo16x16.exe differ diff --git a/obj/Debug/ConvertTo16x16.pdb b/obj/Debug/ConvertTo16x16.pdb new file mode 100644 index 0000000..090a115 Binary files /dev/null and b/obj/Debug/ConvertTo16x16.pdb differ diff --git a/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache index e74b5a3..624e108 100644 Binary files a/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ