Minimal Marketable Product

This commit is contained in:
2022-09-14 19:25:45 +02:00
commit 9afab1667f
15 changed files with 1604 additions and 0 deletions
+86
View File
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D80129BA-FD77-43B2-8A0B-9AF4DCC6569F}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>AgraV2</RootNamespace>
<AssemblyName>AgraV2</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Effect.cs" />
<Compile Include="EffectGrayScale.cs" />
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
+6
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>
+43
View File
@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AgraV2
{
public class Effect
{
private string _name;
private Panel _toolBox;
private List<double> _processingDuration;
private Stopwatch _chrono;
public string Name { get => _name; set => _name = value; }
public Panel ToolBox { get => _toolBox; set => _toolBox = value; }
public List<double> ProcessingDuration { get => _processingDuration; set => _processingDuration = value; }
public Stopwatch Chrono { get => _chrono; set => _chrono = value; }
public Effect(string name, Panel toolBox)
{
Name = name;
ToolBox = toolBox;
ProcessingDuration = new List<double>();
Chrono = new Stopwatch();
//I start and stop it so the child can just always use Restart()
Chrono.Start();Chrono.Stop();
}
public virtual Bitmap[] apply(Bitmap inputBmp)
{
return new Bitmap[] { inputBmp };
}
public override string ToString()
{
return Name;
}
}
}
+137
View File
@@ -0,0 +1,137 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AgraV2
{
internal class EffectGrayScale:Effect
{
private readonly object balancelock = new object();
public EffectGrayScale(string name, Panel toolBox) : base(name, toolBox)
{
//Empty
}
public override Bitmap[] apply(Bitmap inputBmp)
{
if (inputBmp == null)
return null;
Bitmap[] result = new Bitmap[] { useGetSetPixel(inputBmp), useByteArray(inputBmp), usePointers(inputBmp)};
return result;
}
public Bitmap useGetSetPixel(Bitmap inputBmp)
{
Chrono.Restart();
Bitmap outputBmp = new Bitmap(inputBmp.Width, inputBmp.Height);
for (int x = 0; x < inputBmp.Width; x++)
{
for (int y = 0; y < inputBmp.Height; y++)
{
Color pixelColor = inputBmp.GetPixel(x, y);
int grayScale = (Math.Min(pixelColor.R, Math.Min(pixelColor.G, pixelColor.B)) + Math.Max(pixelColor.R, Math.Max(pixelColor.G, pixelColor.B))) / 2;
Color newPixelColor = Color.FromArgb(grayScale, grayScale, grayScale);
outputBmp.SetPixel(x, y, newPixelColor);
}
}
Chrono.Stop();
ProcessingDuration.Add(Chrono.ElapsedMilliseconds / 1000.0);
return outputBmp;
}
public Bitmap useByteArray(Bitmap inputBmp)
{
Chrono.Restart();
Bitmap result = (Bitmap)inputBmp.Clone();
BitmapData xData = result.LockBits(new Rectangle(0, 0, inputBmp.Width, inputBmp.Height), ImageLockMode.ReadWrite, inputBmp.PixelFormat);
int bytesPerPixel = Bitmap.GetPixelFormatSize(inputBmp.PixelFormat) / 8;
int byteCount = xData.Stride * inputBmp.Height;
int offset = xData.Stride - bytesPerPixel * inputBmp.Width;
byte[] data = new byte[byteCount];
Marshal.Copy(xData.Scan0, data, 0, byteCount);
for (int x = 0; x < inputBmp.Width; x++)
{
for (int y = 0; y < inputBmp.Height; y++)
{
int position = y * (bytesPerPixel * inputBmp.Width + offset) + x * bytesPerPixel;
int Blue = data[position];
int Green = data[position + 1];
int Red = data[position + 2];
int grayScale = (Math.Min(Red, Math.Min(Green, Blue)) + Math.Max(Red, Math.Max(Green, Blue))) / 2;
data[position] = (byte)grayScale;
data[position + 1] = (byte)grayScale;
data[position + 2] = (byte)grayScale;
}
}
Marshal.Copy(data, 0, xData.Scan0, data.Length);
result.UnlockBits(xData);
Chrono.Stop();
ProcessingDuration.Add(Chrono.ElapsedMilliseconds / 1000.0);
return result;
}
public unsafe Bitmap usePointers(Bitmap inputBmp)
{
Chrono.Restart();
Bitmap result = (Bitmap)inputBmp.Clone();
BitmapData xData = result.LockBits(new Rectangle(0, 0, inputBmp.Width, inputBmp.Height), ImageLockMode.ReadWrite, inputBmp.PixelFormat);
int bytesPerPixel = Bitmap.GetPixelFormatSize(inputBmp.PixelFormat) / 8;
int byteCount = xData.Stride * inputBmp.Height;
int offset = xData.Stride - bytesPerPixel * inputBmp.Width;
lock (balancelock)
{
byte* startPx = (byte*)xData.Scan0.ToPointer();
byte* cursor = startPx;
for (int x = 0; x < inputBmp.Width; x++)
{
for (int y = 0; y < inputBmp.Height; y++)
{
int Blue = cursor[0];
int Green = cursor[1];
int Red = cursor[2];
int grayScale = (Math.Min(Red, Math.Min(Green, Blue)) + Math.Max(Red, Math.Max(Green, Blue))) / 2;
cursor[0] = (byte)grayScale;
cursor[1] = (byte)grayScale;
cursor[2] = (byte)grayScale;
cursor += bytesPerPixel;
}
//Taking care of the offset
cursor += offset;
}
}
result.UnlockBits(xData);
Chrono.Stop();
ProcessingDuration.Add(Chrono.ElapsedMilliseconds / 1000.0);
return result;
}
}
}
+355
View File
@@ -0,0 +1,355 @@
namespace AgraV2
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.pbxOriginal = new System.Windows.Forms.PictureBox();
this.gpbx1 = new System.Windows.Forms.GroupBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.btnDowload1 = new System.Windows.Forms.Button();
this.pbxResult1 = new System.Windows.Forms.PictureBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.btnDownload2 = new System.Windows.Forms.Button();
this.pbxResult2 = new System.Windows.Forms.PictureBox();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.btnDownload3 = new System.Windows.Forms.Button();
this.pbxResult3 = new System.Windows.Forms.PictureBox();
this.gpbxFiles = new System.Windows.Forms.GroupBox();
this.pnlFiles = new System.Windows.Forms.Panel();
this.btnChangeFolder = new System.Windows.Forms.Button();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.btnApply = new System.Windows.Forms.Button();
this.lsbEffects = new System.Windows.Forms.ListBox();
this.groupBox6 = new System.Windows.Forms.GroupBox();
this.pnlEffectToolbox = new System.Windows.Forms.Panel();
this.lblTimer1 = new System.Windows.Forms.Label();
this.lblTimer2 = new System.Windows.Forms.Label();
this.lblTimer3 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.pbxOriginal)).BeginInit();
this.gpbx1.SuspendLayout();
this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pbxResult1)).BeginInit();
this.groupBox3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pbxResult2)).BeginInit();
this.groupBox4.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pbxResult3)).BeginInit();
this.gpbxFiles.SuspendLayout();
this.groupBox5.SuspendLayout();
this.groupBox6.SuspendLayout();
this.SuspendLayout();
//
// pbxOriginal
//
this.pbxOriginal.Location = new System.Drawing.Point(6, 25);
this.pbxOriginal.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.pbxOriginal.Name = "pbxOriginal";
this.pbxOriginal.Size = new System.Drawing.Size(250, 250);
this.pbxOriginal.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pbxOriginal.TabIndex = 0;
this.pbxOriginal.TabStop = false;
//
// gpbx1
//
this.gpbx1.Controls.Add(this.pbxOriginal);
this.gpbx1.Location = new System.Drawing.Point(12, 12);
this.gpbx1.Name = "gpbx1";
this.gpbx1.Size = new System.Drawing.Size(264, 283);
this.gpbx1.TabIndex = 5;
this.gpbx1.TabStop = false;
this.gpbx1.Text = "Original";
//
// groupBox2
//
this.groupBox2.Controls.Add(this.lblTimer1);
this.groupBox2.Controls.Add(this.btnDowload1);
this.groupBox2.Controls.Add(this.pbxResult1);
this.groupBox2.Location = new System.Drawing.Point(282, 12);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(264, 283);
this.groupBox2.TabIndex = 6;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Result 1";
//
// btnDowload1
//
this.btnDowload1.Location = new System.Drawing.Point(44, 247);
this.btnDowload1.Name = "btnDowload1";
this.btnDowload1.Size = new System.Drawing.Size(168, 28);
this.btnDowload1.TabIndex = 1;
this.btnDowload1.Text = "Download";
this.btnDowload1.UseVisualStyleBackColor = true;
this.btnDowload1.Click += new System.EventHandler(this.btnDowload1_Click);
//
// pbxResult1
//
this.pbxResult1.Location = new System.Drawing.Point(6, 25);
this.pbxResult1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.pbxResult1.Name = "pbxResult1";
this.pbxResult1.Size = new System.Drawing.Size(250, 250);
this.pbxResult1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pbxResult1.TabIndex = 0;
this.pbxResult1.TabStop = false;
//
// groupBox3
//
this.groupBox3.Controls.Add(this.lblTimer2);
this.groupBox3.Controls.Add(this.btnDownload2);
this.groupBox3.Controls.Add(this.pbxResult2);
this.groupBox3.Location = new System.Drawing.Point(12, 301);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(264, 283);
this.groupBox3.TabIndex = 6;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Result 2";
//
// btnDownload2
//
this.btnDownload2.Location = new System.Drawing.Point(44, 247);
this.btnDownload2.Name = "btnDownload2";
this.btnDownload2.Size = new System.Drawing.Size(168, 28);
this.btnDownload2.TabIndex = 1;
this.btnDownload2.Text = "Download";
this.btnDownload2.UseVisualStyleBackColor = true;
this.btnDownload2.Click += new System.EventHandler(this.btnDownload2_Click);
//
// pbxResult2
//
this.pbxResult2.Location = new System.Drawing.Point(6, 25);
this.pbxResult2.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.pbxResult2.Name = "pbxResult2";
this.pbxResult2.Size = new System.Drawing.Size(250, 250);
this.pbxResult2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pbxResult2.TabIndex = 0;
this.pbxResult2.TabStop = false;
//
// groupBox4
//
this.groupBox4.Controls.Add(this.lblTimer3);
this.groupBox4.Controls.Add(this.btnDownload3);
this.groupBox4.Controls.Add(this.pbxResult3);
this.groupBox4.Location = new System.Drawing.Point(282, 301);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(264, 283);
this.groupBox4.TabIndex = 7;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "Result3";
//
// btnDownload3
//
this.btnDownload3.Location = new System.Drawing.Point(44, 247);
this.btnDownload3.Name = "btnDownload3";
this.btnDownload3.Size = new System.Drawing.Size(168, 28);
this.btnDownload3.TabIndex = 1;
this.btnDownload3.Text = "Download";
this.btnDownload3.UseVisualStyleBackColor = true;
this.btnDownload3.Click += new System.EventHandler(this.btnDownload3_Click);
//
// pbxResult3
//
this.pbxResult3.Location = new System.Drawing.Point(6, 25);
this.pbxResult3.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.pbxResult3.Name = "pbxResult3";
this.pbxResult3.Size = new System.Drawing.Size(250, 250);
this.pbxResult3.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pbxResult3.TabIndex = 0;
this.pbxResult3.TabStop = false;
//
// gpbxFiles
//
this.gpbxFiles.Controls.Add(this.pnlFiles);
this.gpbxFiles.Controls.Add(this.btnChangeFolder);
this.gpbxFiles.Location = new System.Drawing.Point(758, 12);
this.gpbxFiles.Name = "gpbxFiles";
this.gpbxFiles.Size = new System.Drawing.Size(200, 573);
this.gpbxFiles.TabIndex = 8;
this.gpbxFiles.TabStop = false;
this.gpbxFiles.Text = "Files";
//
// pnlFiles
//
this.pnlFiles.AutoScroll = true;
this.pnlFiles.Location = new System.Drawing.Point(6, 24);
this.pnlFiles.Name = "pnlFiles";
this.pnlFiles.Size = new System.Drawing.Size(188, 509);
this.pnlFiles.TabIndex = 3;
//
// btnChangeFolder
//
this.btnChangeFolder.Location = new System.Drawing.Point(6, 539);
this.btnChangeFolder.Name = "btnChangeFolder";
this.btnChangeFolder.Size = new System.Drawing.Size(188, 28);
this.btnChangeFolder.TabIndex = 2;
this.btnChangeFolder.Text = "ChangeFolder";
this.btnChangeFolder.UseVisualStyleBackColor = true;
this.btnChangeFolder.Click += new System.EventHandler(this.btnChangeFolder_Click);
//
// groupBox5
//
this.groupBox5.Controls.Add(this.btnApply);
this.groupBox5.Controls.Add(this.lsbEffects);
this.groupBox5.Location = new System.Drawing.Point(552, 12);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(200, 283);
this.groupBox5.TabIndex = 9;
this.groupBox5.TabStop = false;
this.groupBox5.Text = "Effects";
//
// btnApply
//
this.btnApply.Location = new System.Drawing.Point(6, 249);
this.btnApply.Name = "btnApply";
this.btnApply.Size = new System.Drawing.Size(188, 28);
this.btnApply.TabIndex = 3;
this.btnApply.Text = "Apply";
this.btnApply.UseVisualStyleBackColor = true;
this.btnApply.Click += new System.EventHandler(this.btnApply_Click);
//
// lsbEffects
//
this.lsbEffects.FormattingEnabled = true;
this.lsbEffects.ItemHeight = 20;
this.lsbEffects.Location = new System.Drawing.Point(6, 24);
this.lsbEffects.Name = "lsbEffects";
this.lsbEffects.Size = new System.Drawing.Size(188, 204);
this.lsbEffects.TabIndex = 4;
//
// groupBox6
//
this.groupBox6.Controls.Add(this.pnlEffectToolbox);
this.groupBox6.Location = new System.Drawing.Point(552, 302);
this.groupBox6.Name = "groupBox6";
this.groupBox6.Size = new System.Drawing.Size(200, 283);
this.groupBox6.TabIndex = 10;
this.groupBox6.TabStop = false;
this.groupBox6.Text = "Effect toolbox";
//
// pnlEffectToolbox
//
this.pnlEffectToolbox.Location = new System.Drawing.Point(6, 24);
this.pnlEffectToolbox.Name = "pnlEffectToolbox";
this.pnlEffectToolbox.Size = new System.Drawing.Size(188, 250);
this.pnlEffectToolbox.TabIndex = 2;
//
// lblTimer1
//
this.lblTimer1.AutoSize = true;
this.lblTimer1.BackColor = System.Drawing.Color.Black;
this.lblTimer1.ForeColor = System.Drawing.Color.Green;
this.lblTimer1.Location = new System.Drawing.Point(6, 25);
this.lblTimer1.Name = "lblTimer1";
this.lblTimer1.Size = new System.Drawing.Size(54, 20);
this.lblTimer1.TabIndex = 2;
this.lblTimer1.Text = "0.00s";
this.lblTimer1.Visible = false;
//
// lblTimer2
//
this.lblTimer2.AutoSize = true;
this.lblTimer2.BackColor = System.Drawing.Color.Black;
this.lblTimer2.ForeColor = System.Drawing.Color.Green;
this.lblTimer2.Location = new System.Drawing.Point(6, 25);
this.lblTimer2.Name = "lblTimer2";
this.lblTimer2.Size = new System.Drawing.Size(54, 20);
this.lblTimer2.TabIndex = 3;
this.lblTimer2.Text = "0.00s";
this.lblTimer2.Visible = false;
//
// lblTimer3
//
this.lblTimer3.AutoSize = true;
this.lblTimer3.BackColor = System.Drawing.Color.Black;
this.lblTimer3.ForeColor = System.Drawing.Color.Green;
this.lblTimer3.Location = new System.Drawing.Point(6, 25);
this.lblTimer3.Name = "lblTimer3";
this.lblTimer3.Size = new System.Drawing.Size(54, 20);
this.lblTimer3.TabIndex = 4;
this.lblTimer3.Text = "0.00s";
this.lblTimer3.Visible = false;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(968, 593);
this.Controls.Add(this.groupBox6);
this.Controls.Add(this.groupBox5);
this.Controls.Add(this.gpbxFiles);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.gpbx1);
this.Font = new System.Drawing.Font("Cascadia Code SemiBold", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.Name = "Form1";
this.Text = "Agra Sandbox";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.pbxOriginal)).EndInit();
this.gpbx1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pbxResult1)).EndInit();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pbxResult2)).EndInit();
this.groupBox4.ResumeLayout(false);
this.groupBox4.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pbxResult3)).EndInit();
this.gpbxFiles.ResumeLayout(false);
this.groupBox5.ResumeLayout(false);
this.groupBox6.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.PictureBox pbxOriginal;
private System.Windows.Forms.GroupBox gpbx1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Button btnDowload1;
private System.Windows.Forms.PictureBox pbxResult1;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.Button btnDownload2;
private System.Windows.Forms.PictureBox pbxResult2;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.Button btnDownload3;
private System.Windows.Forms.PictureBox pbxResult3;
private System.Windows.Forms.GroupBox gpbxFiles;
private System.Windows.Forms.GroupBox groupBox5;
private System.Windows.Forms.Button btnChangeFolder;
private System.Windows.Forms.Button btnApply;
private System.Windows.Forms.ListBox lsbEffects;
private System.Windows.Forms.GroupBox groupBox6;
private System.Windows.Forms.Panel pnlFiles;
private System.Windows.Forms.Panel pnlEffectToolbox;
private System.Windows.Forms.Label lblTimer1;
private System.Windows.Forms.Label lblTimer2;
private System.Windows.Forms.Label lblTimer3;
}
}
+147
View File
@@ -0,0 +1,147 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AgraV2
{
public partial class Form1 : Form
{
public DirectoryInfo selectedDirectory;
public Bitmap selectedImage;
public List<Effect> effects;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
effects = new List<Effect>();
effects.Add(new EffectGrayScale("GrayScale", pnlEffectToolbox));
RefreshUi();
}
private void RefreshUi()
{
Invalidate();
pbxOriginal.Image = selectedImage;
lsbEffects.DataSource = effects;
}
private void btnChangeFolder_Click(object sender, EventArgs e)
{
const int iconWidthRatio = 1;
const int iconHeightRatio = 10;
FolderBrowserDialog dialog = new FolderBrowserDialog();
if (dialog.ShowDialog() == DialogResult.OK)
{
selectedDirectory = new DirectoryInfo(dialog.SelectedPath);
List<FileInfo> images = new List<FileInfo>();
images.AddRange(selectedDirectory.GetFiles("*.png").ToList<FileInfo>());
images.AddRange(selectedDirectory.GetFiles("*.jpg").ToList<FileInfo>());
PictureBox genericPbx = new PictureBox();
//The -pnlFiles/10 is only here to account for the scrollbar
genericPbx.Size = new Size(pnlFiles.Width / iconWidthRatio - pnlFiles.Width / 10, pnlFiles.Height / iconHeightRatio);
genericPbx.SizeMode = PictureBoxSizeMode.Zoom;
int fileCount = 0;
foreach (FileInfo file in images)
{
string fullName = selectedDirectory.FullName + "\\" + file.Name;
PictureBox currentPbx = new PictureBox();
currentPbx.Size = genericPbx.Size;
currentPbx.SizeMode = genericPbx.SizeMode;
currentPbx.Click += Image_Click;
currentPbx.Location = new Point(0, fileCount * pnlFiles.Height / iconHeightRatio);
currentPbx.Name = fullName;
currentPbx.Image = Image.FromFile(fullName);
pnlFiles.Controls.Add(currentPbx);
fileCount++;
}
}
else
{
MessageBox.Show("Ooops... Could not retrieve folder informations :(");
}
RefreshUi();
}
private void Image_Click(object sender, EventArgs e)
{
if (sender is PictureBox)
{
PictureBox pbx = sender as PictureBox;
selectedImage = (Bitmap)Image.FromFile(pbx.Name);
}
RefreshUi();
}
private void btnApply_Click(object sender, EventArgs e)
{
if (lsbEffects.SelectedIndex >= 0)
{
Effect effect = effects[lsbEffects.SelectedIndex];
Bitmap[] results = effect.apply((Bitmap)pbxOriginal.Image);
if (results != null && results.Length > 0)
{
if (results.Length == 3)
{
pbxResult1.Image = results[0];
pbxResult2.Image = results[1];
pbxResult3.Image = results[2];
if (effect.ProcessingDuration != null && effect.ProcessingDuration.Count > 0)
{
lblTimer1.Visible = lblTimer2.Visible = lblTimer3.Visible = true;
lblTimer1.Text = effect.ProcessingDuration[0] + "s";
lblTimer2.Text = effect.ProcessingDuration[1] + "s";
lblTimer3.Text = effect.ProcessingDuration[2] + "s";
}
}
else
{
pbxResult1.Image = results[0];
if (effect.ProcessingDuration != null && effect.ProcessingDuration.Count > 0)
{
lblTimer1.Visible = true;
lblTimer1.Text = effect.ProcessingDuration[0] + "s";
}
}
}
}
}
private void DownloadImage(Image image)
{
FolderBrowserDialog dialog = new FolderBrowserDialog();
dialog.Description = "SaveImg";
if (dialog.ShowDialog() == DialogResult.OK)
{
string path = dialog.SelectedPath;
image.Save(path + "\\" + "ResultImage.png", System.Drawing.Imaging.ImageFormat.Png);
}
}
private void btnDowload1_Click(object sender, EventArgs e)
{
DownloadImage(pbxResult1.Image);
}
private void btnDownload2_Click(object sender, EventArgs e)
{
DownloadImage(pbxResult2.Image);
}
private void btnDownload3_Click(object sender, EventArgs e)
{
DownloadImage(pbxResult3.Image);
}
}
}
+120
View File
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+22
View File
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AgraV2
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
+36
View File
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("AgraV2")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AgraV2")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("d80129ba-fd77-43b2-8a0b-9af4dcc6569f")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
+71
View File
@@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace AgraV2.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AgraV2.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}
+117
View File
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+30
View File
@@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace AgraV2.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}
+7
View File
@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>