Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////////////////////////////////////
- //FORM1
- ///////////////////////////////////////////////////
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Threading;
- using System.Windows.Forms;
- using Emgu.CV;
- using Emgu.Util;
- using Emgu.CV.Structure;
- using System.IO;
- using System.Drawing.Drawing2D;
- namespace AsciiArtEmguCv
- {
- public partial class Form1 : Form
- {
- String[] chars = File.ReadAllLines("c.txt");
- Image img, scaled;
- Image<Gray, Byte>gray;
- Capture camera;
- int sizex = 200, sizey = 200;
- Form3 f3 = new Form3();
- Form2 f2 = new Form2(), f22 = new Form2();
- double gamma = 1.0, thresh = 1, threshlink = 1;
- public Form1()
- {
- InitializeComponent();
- trackBar1.Value = (int)(gamma*25);
- numericUpDown1.Value = sizex;
- numericUpDown2.Value = sizey;
- numericUpDown3.Value = timer1.Interval;
- }
- private void otwórzToolStripMenuItem_Click(object sender, EventArgs e)
- {
- openFileDialog1.ShowDialog();
- try
- {
- camera = new Capture(openFileDialog1.FileName);
- timer1.Enabled = true;
- }
- catch (TypeInitializationException e1)
- {
- MessageBox.Show("Nie można otworzyć pliku!");
- }
- catch (NullReferenceException e2)
- {
- MessageBox.Show("Nie można otworzyć pliku!");
- }
- catch (ArgumentException e3) { }
- }
- public static Image resize(Image img, Size maxsize, bool keepscale = true)
- {
- double scale;
- double maxsize_scale = maxsize.Width / (double)(maxsize.Height);
- double img_scale = img.Width / (double)(img.Height);
- if (maxsize_scale >= img_scale)
- {
- scale = maxsize.Height / (double)(img.Height);
- }
- else scale = maxsize.Width / (double)(img.Width);
- if (!keepscale)
- return (Image)(new Bitmap(img, maxsize));
- else return (Image)(new Bitmap(img, new Size((int)(img.Width * scale), (int)(img.Height * scale))));
- }
- private void zamknijToolStripMenuItem_Click(object sender, EventArgs e)
- {
- Application.Exit();
- }
- private void otwórzObrazToolStripMenuItem_Click(object sender, EventArgs e)
- {
- openFileDialog1.ShowDialog();
- try
- {
- img = new Bitmap(openFileDialog1.FileName);
- checkBox5.Checked = true;
- imgs();
- button6.Enabled = true;
- }
- catch (NullReferenceException e2)
- {
- MessageBox.Show("Nie można otworzyć pliku!");
- }
- catch (ArgumentException e1) { }
- }
- private void użyjKameryToolStripMenuItem_Click(object sender, EventArgs e)
- {
- try
- {
- camera = new Capture();
- timer1.Enabled = true;
- }
- catch (TypeInitializationException e1)
- {
- MessageBox.Show("Nie można otworzyć pliku!");
- }
- catch (NullReferenceException e2)
- {
- MessageBox.Show("Nie można otworzyć pliku!");
- }
- catch (ArgumentException e3) { }
- }
- private void imgs()
- {
- scaled = resize(img, new Size(sizex, sizey));
- gray = new Image<Gray, Byte>(new Bitmap(scaled));
- gray._GammaCorrect(gamma);
- if (checkBox6.Checked)
- if (radioButton2.Checked)
- gray = gray.Xor(gray.Canny(thresh, threshlink));
- else
- gray = gray.Canny(thresh, threshlink);
- if(checkBox2.Checked)
- gray._EqualizeHist();
- if (checkBox1.Checked)
- gray._Not();
- if (checkBox3.Checked)
- gray._Flip(Emgu.CV.CvEnum.FLIP.HORIZONTAL);
- if (checkBox4.Checked)
- gray._Flip(Emgu.CV.CvEnum.FLIP.VERTICAL);
- if (f2.IsDisposed)
- f2 = new Form2(img);
- else f2.rysuj(img);
- f2.Show();
- if (f22.IsDisposed)
- f22= new Form2(gray.ToBitmap());
- else f22.rysuj(gray.ToBitmap());
- f22.Show();
- analyze();
- }
- private char getchar(double c)
- {
- int n = 0;
- double c1=0;
- while((c1+=(255/chars.Length))<c)
- {
- n++;
- }
- n = chars.Length - n;
- while (n < 0) n++;
- while (n >= chars.Length) n--;
- return chars[n][0];
- }
- private void analyze()
- {
- if (f3.IsDisposed)
- f3 = new Form3();
- string ascii = "";
- double c = 0;
- for (int i = 0; i < gray.Height-3; i+=3)
- {
- for (int j = 0; j < gray.Width-2; j+=2 )
- {
- c = gray.GetSubRect(new Rectangle(new Point(j, i), new Size(2, 3))).GetAverage().Intensity;
- ascii += getchar(c);
- // ascii += getchar(c);
- }
- ascii += "\n";
- }
- f3.label1.Text = ascii;
- if (checkBox5.Checked)
- Clipboard.SetText(ascii);
- f3.Show();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- fontDialog1.FixedPitchOnly = true;
- fontDialog1.ShowDialog();
- f3.label1.Font = fontDialog1.Font;
- }
- private void numericUpDown1_ValueChanged(object sender, EventArgs e)
- {
- sizex = (int)(numericUpDown1.Value);
- }
- private void numericUpDown2_ValueChanged(object sender, EventArgs e)
- {
- sizey = (int)(numericUpDown2.Value);
- }
- private void numericUpDown3_ValueChanged(object sender, EventArgs e)
- {
- timer1.Interval = (int)(numericUpDown3.Value);
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- try
- {
- img = camera.QueryFrame().ToBitmap();
- imgs();
- }
- catch (NullReferenceException e1) { timer1.Enabled = false; }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- if (!timer1.Enabled)
- timer1.Enabled = true;
- else
- timer1.Enabled = false;
- }
- private void trackBar1_Scroll(object sender, EventArgs e)
- {
- gamma = trackBar1.Value / 25.0;
- }
- private void button6_Click(object sender, EventArgs e)
- {
- imgs();
- }
- private void checkBox6_CheckedChanged(object sender, EventArgs e)
- {
- if (checkBox6.Checked)
- groupBox1.Enabled = true;
- else
- groupBox1.Enabled = false;
- }
- private void trackBar2_Scroll(object sender, EventArgs e)
- {
- thresh = trackBar2.Value;
- }
- private void trackBar3_Scroll(object sender, EventArgs e)
- {
- threshlink = trackBar3.Value;
- }
- }
- }
- ////////////////////////////////////////////////////////////////////
- //Form1.designer
- namespace AsciiArtEmguCv
- {
- 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.components = new System.ComponentModel.Container();
- this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
- this.menuStrip1 = new System.Windows.Forms.MenuStrip();
- this.plikToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.otwórzObrazToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.otwórzToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.użyjKameryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
- this.zamknijToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.label1 = new System.Windows.Forms.Label();
- this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
- this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
- this.label2 = new System.Windows.Forms.Label();
- this.label3 = new System.Windows.Forms.Label();
- this.fontDialog1 = new System.Windows.Forms.FontDialog();
- this.button1 = new System.Windows.Forms.Button();
- this.checkBox1 = new System.Windows.Forms.CheckBox();
- this.timer1 = new System.Windows.Forms.Timer(this.components);
- this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();
- this.label4 = new System.Windows.Forms.Label();
- this.button2 = new System.Windows.Forms.Button();
- this.trackBar1 = new System.Windows.Forms.TrackBar();
- this.label5 = new System.Windows.Forms.Label();
- this.checkBox2 = new System.Windows.Forms.CheckBox();
- this.button3 = new System.Windows.Forms.Button();
- this.button4 = new System.Windows.Forms.Button();
- this.button5 = new System.Windows.Forms.Button();
- this.checkBox3 = new System.Windows.Forms.CheckBox();
- this.checkBox4 = new System.Windows.Forms.CheckBox();
- this.button6 = new System.Windows.Forms.Button();
- this.checkBox5 = new System.Windows.Forms.CheckBox();
- this.checkBox6 = new System.Windows.Forms.CheckBox();
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.radioButton1 = new System.Windows.Forms.RadioButton();
- this.radioButton2 = new System.Windows.Forms.RadioButton();
- this.trackBar2 = new System.Windows.Forms.TrackBar();
- this.trackBar3 = new System.Windows.Forms.TrackBar();
- this.label6 = new System.Windows.Forms.Label();
- this.label7 = new System.Windows.Forms.Label();
- this.menuStrip1.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
- this.groupBox1.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.trackBar2)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.trackBar3)).BeginInit();
- this.SuspendLayout();
- //
- // openFileDialog1
- //
- this.openFileDialog1.FileName = "openFileDialog1";
- //
- // menuStrip1
- //
- this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.plikToolStripMenuItem});
- this.menuStrip1.Location = new System.Drawing.Point(0, 0);
- this.menuStrip1.Name = "menuStrip1";
- this.menuStrip1.Size = new System.Drawing.Size(368, 24);
- this.menuStrip1.TabIndex = 0;
- this.menuStrip1.Text = "menuStrip1";
- //
- // plikToolStripMenuItem
- //
- this.plikToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.otwórzObrazToolStripMenuItem,
- this.otwórzToolStripMenuItem,
- this.użyjKameryToolStripMenuItem,
- this.toolStripSeparator1,
- this.zamknijToolStripMenuItem});
- this.plikToolStripMenuItem.Name = "plikToolStripMenuItem";
- this.plikToolStripMenuItem.Size = new System.Drawing.Size(38, 20);
- this.plikToolStripMenuItem.Text = "Plik";
- //
- // otwórzObrazToolStripMenuItem
- //
- this.otwórzObrazToolStripMenuItem.Name = "otwórzObrazToolStripMenuItem";
- this.otwórzObrazToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
- this.otwórzObrazToolStripMenuItem.Size = new System.Drawing.Size(189, 22);
- this.otwórzObrazToolStripMenuItem.Text = "Otwórz Obraz";
- this.otwórzObrazToolStripMenuItem.Click += new System.EventHandler(this.otwórzObrazToolStripMenuItem_Click);
- //
- // otwórzToolStripMenuItem
- //
- this.otwórzToolStripMenuItem.Name = "otwórzToolStripMenuItem";
- this.otwórzToolStripMenuItem.Size = new System.Drawing.Size(189, 22);
- this.otwórzToolStripMenuItem.Text = "Otwórz Wideo";
- this.otwórzToolStripMenuItem.Click += new System.EventHandler(this.otwórzToolStripMenuItem_Click);
- //
- // użyjKameryToolStripMenuItem
- //
- this.użyjKameryToolStripMenuItem.Name = "użyjKameryToolStripMenuItem";
- this.użyjKameryToolStripMenuItem.Size = new System.Drawing.Size(189, 22);
- this.użyjKameryToolStripMenuItem.Text = "Użyj kamery";
- this.użyjKameryToolStripMenuItem.Click += new System.EventHandler(this.użyjKameryToolStripMenuItem_Click);
- //
- // toolStripSeparator1
- //
- this.toolStripSeparator1.Name = "toolStripSeparator1";
- this.toolStripSeparator1.Size = new System.Drawing.Size(186, 6);
- //
- // zamknijToolStripMenuItem
- //
- this.zamknijToolStripMenuItem.Name = "zamknijToolStripMenuItem";
- this.zamknijToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Q)));
- this.zamknijToolStripMenuItem.Size = new System.Drawing.Size(189, 22);
- this.zamknijToolStripMenuItem.Text = "Zamknij";
- this.zamknijToolStripMenuItem.Click += new System.EventHandler(this.zamknijToolStripMenuItem_Click);
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(15, 101);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(45, 13);
- this.label1.TabIndex = 1;
- this.label1.Text = "Rozmiar";
- //
- // numericUpDown1
- //
- this.numericUpDown1.Location = new System.Drawing.Point(38, 126);
- this.numericUpDown1.Maximum = new decimal(new int[] {
- 1000,
- 0,
- 0,
- 0});
- this.numericUpDown1.Name = "numericUpDown1";
- this.numericUpDown1.Size = new System.Drawing.Size(71, 20);
- this.numericUpDown1.TabIndex = 2;
- this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
- //
- // numericUpDown2
- //
- this.numericUpDown2.Location = new System.Drawing.Point(38, 152);
- this.numericUpDown2.Maximum = new decimal(new int[] {
- 1000,
- 0,
- 0,
- 0});
- this.numericUpDown2.Name = "numericUpDown2";
- this.numericUpDown2.Size = new System.Drawing.Size(71, 20);
- this.numericUpDown2.TabIndex = 2;
- this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged);
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(15, 128);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(17, 13);
- this.label2.TabIndex = 1;
- this.label2.Text = "X:";
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(15, 154);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(17, 13);
- this.label3.TabIndex = 1;
- this.label3.Text = "Y:";
- //
- // fontDialog1
- //
- this.fontDialog1.FixedPitchOnly = true;
- //
- // button1
- //
- this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
- this.button1.Location = new System.Drawing.Point(18, 188);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(94, 42);
- this.button1.TabIndex = 3;
- this.button1.Text = "Czcionka Ascii Art";
- this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // checkBox1
- //
- this.checkBox1.AutoSize = true;
- this.checkBox1.Location = new System.Drawing.Point(201, 129);
- this.checkBox1.Name = "checkBox1";
- this.checkBox1.Size = new System.Drawing.Size(94, 17);
- this.checkBox1.TabIndex = 4;
- this.checkBox1.Text = "Odwróć kolory";
- this.checkBox1.UseVisualStyleBackColor = true;
- //
- // timer1
- //
- this.timer1.Interval = 30;
- this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
- //
- // numericUpDown3
- //
- this.numericUpDown3.Location = new System.Drawing.Point(15, 273);
- this.numericUpDown3.Maximum = new decimal(new int[] {
- 1000,
- 0,
- 0,
- 0});
- this.numericUpDown3.Name = "numericUpDown3";
- this.numericUpDown3.Size = new System.Drawing.Size(94, 20);
- this.numericUpDown3.TabIndex = 5;
- this.numericUpDown3.ValueChanged += new System.EventHandler(this.numericUpDown3_ValueChanged);
- //
- // label4
- //
- this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(15, 248);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(161, 13);
- this.label4.TabIndex = 1;
- this.label4.Text = "Interwał stopera (wideo/kamera)";
- //
- // button2
- //
- this.button2.Location = new System.Drawing.Point(201, 250);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(94, 43);
- this.button2.TabIndex = 6;
- this.button2.Text = "Pauza (wideo/kamera)";
- this.button2.UseVisualStyleBackColor = true;
- this.button2.Click += new System.EventHandler(this.button2_Click);
- //
- // trackBar1
- //
- this.trackBar1.LargeChange = 10;
- this.trackBar1.Location = new System.Drawing.Point(15, 336);
- this.trackBar1.Maximum = 50;
- this.trackBar1.Minimum = 1;
- this.trackBar1.Name = "trackBar1";
- this.trackBar1.Size = new System.Drawing.Size(269, 45);
- this.trackBar1.TabIndex = 7;
- this.trackBar1.Value = 1;
- this.trackBar1.Scroll += new System.EventHandler(this.trackBar1_Scroll);
- //
- // label5
- //
- this.label5.AutoSize = true;
- this.label5.Location = new System.Drawing.Point(15, 320);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(43, 13);
- this.label5.TabIndex = 1;
- this.label5.Text = "Gamma";
- //
- // checkBox2
- //
- this.checkBox2.AutoSize = true;
- this.checkBox2.Location = new System.Drawing.Point(201, 152);
- this.checkBox2.Name = "checkBox2";
- this.checkBox2.Size = new System.Drawing.Size(106, 17);
- this.checkBox2.TabIndex = 8;
- this.checkBox2.Text = "Zwiększ kontrast";
- this.checkBox2.UseVisualStyleBackColor = true;
- //
- // button3
- //
- this.button3.Location = new System.Drawing.Point(15, 38);
- this.button3.Name = "button3";
- this.button3.Size = new System.Drawing.Size(75, 23);
- this.button3.TabIndex = 9;
- this.button3.Text = "Obraz";
- this.button3.UseVisualStyleBackColor = true;
- this.button3.Click += new System.EventHandler(this.otwórzObrazToolStripMenuItem_Click);
- //
- // button4
- //
- this.button4.Location = new System.Drawing.Point(117, 38);
- this.button4.Name = "button4";
- this.button4.Size = new System.Drawing.Size(75, 23);
- this.button4.TabIndex = 9;
- this.button4.Text = "Wideo";
- this.button4.UseVisualStyleBackColor = true;
- this.button4.Click += new System.EventHandler(this.otwórzToolStripMenuItem_Click);
- //
- // button5
- //
- this.button5.Location = new System.Drawing.Point(219, 38);
- this.button5.Name = "button5";
- this.button5.Size = new System.Drawing.Size(75, 23);
- this.button5.TabIndex = 9;
- this.button5.Text = "Kamera";
- this.button5.UseVisualStyleBackColor = true;
- this.button5.Click += new System.EventHandler(this.użyjKameryToolStripMenuItem_Click);
- //
- // checkBox3
- //
- this.checkBox3.AutoSize = true;
- this.checkBox3.Location = new System.Drawing.Point(201, 175);
- this.checkBox3.Name = "checkBox3";
- this.checkBox3.Size = new System.Drawing.Size(117, 17);
- this.checkBox3.TabIndex = 8;
- this.checkBox3.Text = "Odbicie w poziomie";
- this.checkBox3.UseVisualStyleBackColor = true;
- //
- // checkBox4
- //
- this.checkBox4.AutoSize = true;
- this.checkBox4.Location = new System.Drawing.Point(201, 198);
- this.checkBox4.Name = "checkBox4";
- this.checkBox4.Size = new System.Drawing.Size(102, 17);
- this.checkBox4.TabIndex = 8;
- this.checkBox4.Text = "Odbicie w pione";
- this.checkBox4.UseVisualStyleBackColor = true;
- //
- // button6
- //
- this.button6.Enabled = false;
- this.button6.Location = new System.Drawing.Point(15, 67);
- this.button6.Name = "button6";
- this.button6.Size = new System.Drawing.Size(75, 23);
- this.button6.TabIndex = 9;
- this.button6.Text = "Odśwież";
- this.button6.UseVisualStyleBackColor = true;
- this.button6.Click += new System.EventHandler(this.button6_Click);
- //
- // checkBox5
- //
- this.checkBox5.AutoSize = true;
- this.checkBox5.Location = new System.Drawing.Point(18, 376);
- this.checkBox5.Name = "checkBox5";
- this.checkBox5.Size = new System.Drawing.Size(246, 17);
- this.checkBox5.TabIndex = 8;
- this.checkBox5.Text = "Kopiuj AsciiArt do schowka po wygenerowaniu";
- this.checkBox5.UseVisualStyleBackColor = true;
- //
- // checkBox6
- //
- this.checkBox6.AutoSize = true;
- this.checkBox6.Location = new System.Drawing.Point(18, 418);
- this.checkBox6.Name = "checkBox6";
- this.checkBox6.Size = new System.Drawing.Size(123, 17);
- this.checkBox6.TabIndex = 10;
- this.checkBox6.Text = "Wykrywaj krawędzie";
- this.checkBox6.UseVisualStyleBackColor = true;
- this.checkBox6.CheckedChanged += new System.EventHandler(this.checkBox6_CheckedChanged);
- //
- // groupBox1
- //
- this.groupBox1.Controls.Add(this.radioButton2);
- this.groupBox1.Controls.Add(this.radioButton1);
- this.groupBox1.Controls.Add(this.trackBar3);
- this.groupBox1.Controls.Add(this.trackBar2);
- this.groupBox1.Controls.Add(this.label7);
- this.groupBox1.Controls.Add(this.label6);
- this.groupBox1.Enabled = false;
- this.groupBox1.Location = new System.Drawing.Point(18, 441);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(319, 250);
- this.groupBox1.TabIndex = 11;
- this.groupBox1.TabStop = false;
- //
- // radioButton1
- //
- this.radioButton1.AutoSize = true;
- this.radioButton1.Checked = true;
- this.radioButton1.Location = new System.Drawing.Point(20, 19);
- this.radioButton1.Name = "radioButton1";
- this.radioButton1.Size = new System.Drawing.Size(74, 17);
- this.radioButton1.TabIndex = 11;
- this.radioButton1.TabStop = true;
- this.radioButton1.Text = "Krawędzie";
- this.radioButton1.UseVisualStyleBackColor = true;
- //
- // radioButton2
- //
- this.radioButton2.AutoSize = true;
- this.radioButton2.Location = new System.Drawing.Point(20, 42);
- this.radioButton2.Name = "radioButton2";
- this.radioButton2.Size = new System.Drawing.Size(41, 17);
- this.radioButton2.TabIndex = 11;
- this.radioButton2.TabStop = true;
- this.radioButton2.Text = "Xor";
- this.radioButton2.UseVisualStyleBackColor = true;
- //
- // trackBar2
- //
- this.trackBar2.LargeChange = 10;
- this.trackBar2.Location = new System.Drawing.Point(20, 112);
- this.trackBar2.Maximum = 100;
- this.trackBar2.Minimum = 1;
- this.trackBar2.Name = "trackBar2";
- this.trackBar2.Size = new System.Drawing.Size(269, 45);
- this.trackBar2.TabIndex = 7;
- this.trackBar2.Value = 1;
- this.trackBar2.Scroll += new System.EventHandler(this.trackBar2_Scroll);
- //
- // trackBar3
- //
- this.trackBar3.LargeChange = 10;
- this.trackBar3.Location = new System.Drawing.Point(16, 187);
- this.trackBar3.Maximum = 100;
- this.trackBar3.Minimum = 1;
- this.trackBar3.Name = "trackBar3";
- this.trackBar3.Size = new System.Drawing.Size(269, 45);
- this.trackBar3.TabIndex = 7;
- this.trackBar3.Value = 1;
- this.trackBar3.Scroll += new System.EventHandler(this.trackBar3_Scroll);
- //
- // label6
- //
- this.label6.AutoSize = true;
- this.label6.Location = new System.Drawing.Point(13, 86);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(91, 13);
- this.label6.TabIndex = 1;
- this.label6.Text = "Próg znajdowania";
- //
- // label7
- //
- this.label7.AutoSize = true;
- this.label7.Location = new System.Drawing.Point(13, 160);
- this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(73, 13);
- this.label7.TabIndex = 1;
- this.label7.Text = "Próg łączenia";
- //
- // Form1
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(368, 734);
- this.MinimumSize = this.ClientSize;
- this.MaximumSize = this.ClientSize;
- this.Controls.Add(this.groupBox1);
- this.Controls.Add(this.button5);
- this.Controls.Add(this.checkBox6);
- this.Controls.Add(this.button4);
- this.Controls.Add(this.button6);
- this.Controls.Add(this.button3);
- this.Controls.Add(this.checkBox5);
- this.Controls.Add(this.checkBox4);
- this.Controls.Add(this.checkBox3);
- this.Controls.Add(this.checkBox2);
- this.Controls.Add(this.trackBar1);
- this.Controls.Add(this.button2);
- this.Controls.Add(this.numericUpDown3);
- this.Controls.Add(this.checkBox1);
- this.Controls.Add(this.button1);
- this.Controls.Add(this.numericUpDown2);
- this.Controls.Add(this.numericUpDown1);
- this.Controls.Add(this.label3);
- this.Controls.Add(this.label2);
- this.Controls.Add(this.label4);
- this.Controls.Add(this.label5);
- this.Controls.Add(this.label1);
- this.Controls.Add(this.menuStrip1);
- this.MainMenuStrip = this.menuStrip1;
- this.Name = "Form1";
- this.Text = "Form1";
- this.menuStrip1.ResumeLayout(false);
- this.menuStrip1.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
- this.groupBox1.ResumeLayout(false);
- this.groupBox1.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.trackBar2)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.trackBar3)).EndInit();
- this.ResumeLayout(false);
- this.PerformLayout();
- }
- #endregion
- private System.Windows.Forms.OpenFileDialog openFileDialog1;
- private System.Windows.Forms.MenuStrip menuStrip1;
- private System.Windows.Forms.ToolStripMenuItem plikToolStripMenuItem;
- private System.Windows.Forms.ToolStripMenuItem otwórzToolStripMenuItem;
- private System.Windows.Forms.ToolStripMenuItem zamknijToolStripMenuItem;
- private System.Windows.Forms.ToolStripMenuItem otwórzObrazToolStripMenuItem;
- private System.Windows.Forms.ToolStripMenuItem użyjKameryToolStripMenuItem;
- private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.NumericUpDown numericUpDown1;
- private System.Windows.Forms.NumericUpDown numericUpDown2;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.Label label3;
- private System.Windows.Forms.Button button1;
- public System.Windows.Forms.FontDialog fontDialog1;
- private System.Windows.Forms.CheckBox checkBox1;
- private System.Windows.Forms.Timer timer1;
- private System.Windows.Forms.NumericUpDown numericUpDown3;
- private System.Windows.Forms.Label label4;
- private System.Windows.Forms.Button button2;
- private System.Windows.Forms.TrackBar trackBar1;
- private System.Windows.Forms.Label label5;
- private System.Windows.Forms.CheckBox checkBox2;
- private System.Windows.Forms.Button button3;
- private System.Windows.Forms.Button button4;
- private System.Windows.Forms.Button button5;
- private System.Windows.Forms.CheckBox checkBox3;
- private System.Windows.Forms.CheckBox checkBox4;
- private System.Windows.Forms.Button button6;
- private System.Windows.Forms.CheckBox checkBox5;
- private System.Windows.Forms.CheckBox checkBox6;
- private System.Windows.Forms.GroupBox groupBox1;
- private System.Windows.Forms.RadioButton radioButton2;
- private System.Windows.Forms.RadioButton radioButton1;
- private System.Windows.Forms.TrackBar trackBar3;
- private System.Windows.Forms.TrackBar trackBar2;
- private System.Windows.Forms.Label label7;
- private System.Windows.Forms.Label label6;
- }
- }
- ////////////////////////////////////////////////////////////////
- //FORM2
- ///////////////////////////////////////////////////////////////
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using Emgu.CV;
- using Emgu.Util;
- using Emgu.CV.Structure;
- namespace AsciiArtEmguCv
- {
- public partial class Form2 : Form
- {
- public Form2()
- {
- InitializeComponent();
- }
- public Form2(Image img)
- {
- InitializeComponent();
- if (img.Size.Width > 1600 || img.Size.Height > 900)
- pictureBox1.Image = Form1.resize(img, new Size(1600, 900));
- else
- pictureBox1.Image = img;
- }
- public void rysuj(Image img)
- {
- if (img.Size.Width > 1600 || img.Size.Height > 900)
- pictureBox1.Image = Form1.resize(img, new Size(1600, 900));
- else
- pictureBox1.Image = img;
- }
- }
- }
- /////////////////////////////////////////////////
- //Form2.desinger
- namespace AsciiArtEmguCv
- {
- partial class Form2
- {
- /// <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.pictureBox1 = new System.Windows.Forms.PictureBox();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
- this.SuspendLayout();
- //
- // pictureBox1
- //
- this.pictureBox1.Location = new System.Drawing.Point(0, 0);
- this.pictureBox1.MaximumSize = new System.Drawing.Size(1600, 900);
- this.pictureBox1.Name = "pictureBox1";
- this.pictureBox1.Size = new System.Drawing.Size(381, 334);
- this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
- this.pictureBox1.TabIndex = 0;
- this.pictureBox1.TabStop = false;
- //
- // Form2
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.AutoSize = true;
- this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
- this.ClientSize = new System.Drawing.Size(381, 334);
- this.Controls.Add(this.pictureBox1);
- this.Name = "Form2";
- this.Text = "Bitmap";
- ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
- this.ResumeLayout(false);
- this.PerformLayout();
- }
- #endregion
- private System.Windows.Forms.PictureBox pictureBox1;
- }
- }
- //////////////////////////////////////////////////////
- //Form3.desinger
- /////////////////////////////////////////////////////
- namespace AsciiArtEmguCv
- {
- partial class Form3
- {
- /// <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.label1 = new System.Windows.Forms.Label();
- this.SuspendLayout();
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Font = new System.Drawing.Font("Lucida Console", 6F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(238)));
- this.label1.Location = new System.Drawing.Point(10, 6);
- this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(0, 6);
- this.label1.TabIndex = 0;
- //
- // Form3
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(5F, 8F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.AutoSize = true;
- this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
- this.ClientSize = new System.Drawing.Size(236, 161);
- this.Controls.Add(this.label1);
- this.Font = new System.Drawing.Font("Lucida Console", 6F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
- this.Margin = new System.Windows.Forms.Padding(2);
- this.Name = "Form3";
- this.Text = "AsciiArt";
- this.ResumeLayout(false);
- this.PerformLayout();
- }
- #endregion
- public System.Windows.Forms.Label label1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment