First working solution

This commit is contained in:
Pablu23
2020-06-25 12:23:22 +02:00
parent 72a858431f
commit 3cbc44435e
10 changed files with 96 additions and 0 deletions

View File

@@ -35,6 +35,7 @@
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />

View File

@@ -3,13 +3,96 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Drawing;
namespace ConvertTo16x16 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 class Program
{ {
static void Main(string[] args) 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<Count> Argb = new List<Count>();
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}");
} }
} }
} }

Binary file not shown.

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

Binary file not shown.

View File

@@ -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

Binary file not shown.

Binary file not shown.