From 8d618995d86b671853611b2bd35f65503109e65d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Hompus?= Date: Fri, 5 Feb 2021 13:43:01 +0100 Subject: [PATCH] Add project files. --- Pixcel.sln | 25 ++++++++++++++++++++++++ Pixcel/Pixcel.csproj | 20 +++++++++++++++++++ Pixcel/Program.cs | 28 +++++++++++++++++++++++++++ Pixcel/Properties/launchSettings.json | 8 ++++++++ 4 files changed, 81 insertions(+) create mode 100644 Pixcel.sln create mode 100644 Pixcel/Pixcel.csproj create mode 100644 Pixcel/Program.cs create mode 100644 Pixcel/Properties/launchSettings.json diff --git a/Pixcel.sln b/Pixcel.sln new file mode 100644 index 0000000..e9752c9 --- /dev/null +++ b/Pixcel.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30804.86 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pixcel", "Pixcel\Pixcel.csproj", "{5C53F119-B7F4-4224-A90F-225D66BC5D12}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5C53F119-B7F4-4224-A90F-225D66BC5D12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5C53F119-B7F4-4224-A90F-225D66BC5D12}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5C53F119-B7F4-4224-A90F-225D66BC5D12}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5C53F119-B7F4-4224-A90F-225D66BC5D12}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {6E63A6E5-8FB0-4A9E-9975-D0F472EB1257} + EndGlobalSection +EndGlobal diff --git a/Pixcel/Pixcel.csproj b/Pixcel/Pixcel.csproj new file mode 100644 index 0000000..2d8e1de --- /dev/null +++ b/Pixcel/Pixcel.csproj @@ -0,0 +1,20 @@ + + + + Exe + net5.0 + enable + Michaël Hompus + MIT + + + + x64 + true + + + + + + + diff --git a/Pixcel/Program.cs b/Pixcel/Program.cs new file mode 100644 index 0000000..aa04d30 --- /dev/null +++ b/Pixcel/Program.cs @@ -0,0 +1,28 @@ +using OfficeOpenXml; +using OfficeOpenXml.Style; +using System.Drawing; +using System.IO; + +var source = args[0]; + +var bitmap = new Bitmap(64, 64); +using var graphics = Graphics.FromImage(bitmap); +graphics.DrawImage(new Bitmap(source), 0, 0, 64, 64); + +ExcelPackage.LicenseContext = LicenseContext.NonCommercial; +using var package = new ExcelPackage(new FileInfo(source.Replace(Path.GetExtension(source), ".xlsx"))); +var worksheet = package.Workbook.Worksheets["Pixcel"] ?? package.Workbook.Worksheets.Add("Pixcel"); + +for (int y = 1; y <= bitmap.Width; y++) +{ + worksheet.Column(y).Width = 5; + + for (int x = 1; x <= bitmap.Height; x++) + { + worksheet.Row(x).Height = 25; + worksheet.Cells[x, y].Style.Fill.PatternType = ExcelFillStyle.Solid; + worksheet.Cells[x, y].Style.Fill.BackgroundColor.SetColor(bitmap.GetPixel(y - 1, x - 1)); + } +} + +package.Save(); \ No newline at end of file diff --git a/Pixcel/Properties/launchSettings.json b/Pixcel/Properties/launchSettings.json new file mode 100644 index 0000000..3dffe09 --- /dev/null +++ b/Pixcel/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Pixcel": { + "commandName": "Project", + "commandLineArgs": "\"C:\\Users\\micha\\Pictures\\Info Support\\Profile1000x1000.jpg\"" + } + } +} \ No newline at end of file