From a4cc89b82647977b6f91028dbc4f2e10d648a546 Mon Sep 17 00:00:00 2001 From: Johannes Date: Wed, 16 Jul 2014 22:12:07 +0200 Subject: [PATCH] Added flood fill --- MagicPaint/FastBitmap.cs | 79 +++++ MagicPaint/Form1.Designer.cs | 337 ++++++++++---------- MagicPaint/Form1.cs | 10 + MagicPaint/Form1.resx | 42 +-- MagicPaint/MagicPaint.csproj | 3 + MagicPaint/MagicPixler.cs | 45 ++- MagicPaint/Properties/Resources.Designer.cs | 64 ++-- MagicPaint/Properties/Resources.resx | 70 +++- MagicPaint/Resources/fill-color.png | Bin 0 -> 2508 bytes MagicPaint/Resources/license_icons.txt | 30 ++ 10 files changed, 458 insertions(+), 222 deletions(-) create mode 100644 MagicPaint/FastBitmap.cs create mode 100644 MagicPaint/Resources/fill-color.png create mode 100644 MagicPaint/Resources/license_icons.txt diff --git a/MagicPaint/FastBitmap.cs b/MagicPaint/FastBitmap.cs new file mode 100644 index 0000000..58757c0 --- /dev/null +++ b/MagicPaint/FastBitmap.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Drawing; +using System.Drawing.Imaging; + +namespace MagicPaint +{ + // Thanks to: http://www.vcskicks.com/fast-image-processing2.php + unsafe public class FastBitmap + { + private struct PixelData + { + public byte blue; + public byte green; + public byte red; + public byte alpha; + + public override string ToString() + { + return "(" + alpha.ToString() + ", " + red.ToString() + ", " + green.ToString() + ", " + blue.ToString() + ")"; + } + } + + private Bitmap workingBitmap = null; + private int width = 0; + private BitmapData bitmapData = null; + private Byte* pBase = null; + + public FastBitmap(Bitmap inputBitmap) + { + workingBitmap = inputBitmap; + } + + public void LockImage() + { + Rectangle bounds = new Rectangle(Point.Empty, workingBitmap.Size); + + width = (int)(bounds.Width * sizeof(PixelData)); + if (width % 4 != 0) width = 4 * (width / 4 + 1); + + //Lock Image + bitmapData = workingBitmap.LockBits(bounds, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb); + pBase = (Byte*)bitmapData.Scan0.ToPointer(); + } + + private PixelData* pixelData = null; + + public Color GetPixel(int x, int y) + { + pixelData = (PixelData*)(pBase + y * width + x * sizeof(PixelData)); + return Color.FromArgb(pixelData->alpha, pixelData->red, pixelData->green, pixelData->blue); + } + + public Color GetPixelNext() + { + pixelData++; + return Color.FromArgb(pixelData->alpha, pixelData->red, pixelData->green, pixelData->blue); + } + + public void SetPixel(int x, int y, Color color) + { + PixelData* data = (PixelData*)(pBase + y * width + x * sizeof(PixelData)); + data->alpha = color.A; + data->red = color.R; + data->green = color.G; + data->blue = color.B; + } + + public void UnlockImage() + { + workingBitmap.UnlockBits(bitmapData); + bitmapData = null; + pBase = null; + } + } +} diff --git a/MagicPaint/Form1.Designer.cs b/MagicPaint/Form1.Designer.cs index 80c5027..da59d15 100644 --- a/MagicPaint/Form1.Designer.cs +++ b/MagicPaint/Form1.Designer.cs @@ -30,37 +30,38 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); this.toolStrip1 = new System.Windows.Forms.ToolStrip(); - this.btnNew = new System.Windows.Forms.ToolStripButton(); - this.btnOpenFile = new System.Windows.Forms.ToolStripButton(); - this.btnImportFile = new System.Windows.Forms.ToolStripButton(); - this.btnSave = new System.Windows.Forms.ToolStripButton(); - this.btnSaveAs = new System.Windows.Forms.ToolStripButton(); - this.btnUploadToDevice = new System.Windows.Forms.ToolStripButton(); - this.btnAbout = new System.Windows.Forms.ToolStripButton(); this.trackFrames = new System.Windows.Forms.TrackBar(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.lstFileInfos = new System.Windows.Forms.ListView(); this.key = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.value = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.pnlFrames = new System.Windows.Forms.GroupBox(); - this.btnAddFrameFromImage = new System.Windows.Forms.Button(); - this.btnRemoveFrame = new System.Windows.Forms.Button(); - this.btnAddFrame = new System.Windows.Forms.Button(); - this.btnResetFrame = new System.Windows.Forms.Button(); - this.btnSaveFrame = new System.Windows.Forms.Button(); this.lblFrameNumber = new System.Windows.Forms.Label(); - this.btnNextFrame = new System.Windows.Forms.Button(); - this.btnPreviousFrame = new System.Windows.Forms.Button(); this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); this.panel1 = new System.Windows.Forms.Panel(); - this.pnlCurrentColor = new System.Windows.Forms.PictureBox(); - this.btnToolColorPicker = new System.Windows.Forms.Button(); - this.btnToolBrush = new System.Windows.Forms.Button(); + this.btnToolFill = new System.Windows.Forms.Button(); this.colorDialog1 = new System.Windows.Forms.ColorDialog(); this.trackZoom = new System.Windows.Forms.TrackBar(); this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); - this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.pnlCurrentColor = new System.Windows.Forms.PictureBox(); + this.btnToolColorPicker = new System.Windows.Forms.Button(); + this.btnToolBrush = new System.Windows.Forms.Button(); + this.btnAddFrameFromImage = new System.Windows.Forms.Button(); + this.btnRemoveFrame = new System.Windows.Forms.Button(); + this.btnAddFrame = new System.Windows.Forms.Button(); + this.btnResetFrame = new System.Windows.Forms.Button(); + this.btnSaveFrame = new System.Windows.Forms.Button(); + this.btnNextFrame = new System.Windows.Forms.Button(); + this.btnPreviousFrame = new System.Windows.Forms.Button(); + this.btnNew = new System.Windows.Forms.ToolStripButton(); + this.btnOpenFile = new System.Windows.Forms.ToolStripButton(); + this.btnImportFile = new System.Windows.Forms.ToolStripButton(); + this.btnSave = new System.Windows.Forms.ToolStripButton(); + this.btnSaveAs = new System.Windows.Forms.ToolStripButton(); + this.btnUploadToDevice = new System.Windows.Forms.ToolStripButton(); + this.btnAbout = new System.Windows.Forms.ToolStripButton(); this.palette1 = new MagicPaint.Palette(); this.magicPixler1 = new MagicPaint.MagicPixler(); this.toolStrip1.SuspendLayout(); @@ -68,10 +69,10 @@ private void InitializeComponent() this.groupBox1.SuspendLayout(); this.pnlFrames.SuspendLayout(); this.panel1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pnlCurrentColor)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.trackZoom)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.groupBox2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pnlCurrentColor)).BeginInit(); this.SuspendLayout(); // // toolStrip1 @@ -90,69 +91,6 @@ private void InitializeComponent() this.toolStrip1.TabIndex = 0; this.toolStrip1.Text = "toolStrip1"; // - // btnNew - // - this.btnNew.Image = global::MagicPaint.Properties.Resources.newdoc; - this.btnNew.ImageTransparentColor = System.Drawing.Color.Magenta; - this.btnNew.Name = "btnNew"; - this.btnNew.Size = new System.Drawing.Size(51, 22); - this.btnNew.Text = "New"; - this.btnNew.Click += new System.EventHandler(this.btnNew_Click); - // - // btnOpenFile - // - this.btnOpenFile.Image = ((System.Drawing.Image)(resources.GetObject("btnOpenFile.Image"))); - this.btnOpenFile.ImageTransparentColor = System.Drawing.Color.Magenta; - this.btnOpenFile.Name = "btnOpenFile"; - this.btnOpenFile.Size = new System.Drawing.Size(56, 22); - this.btnOpenFile.Text = "Open"; - this.btnOpenFile.Click += new System.EventHandler(this.btnOpenFile_Click); - // - // btnImportFile - // - this.btnImportFile.Image = ((System.Drawing.Image)(resources.GetObject("btnImportFile.Image"))); - this.btnImportFile.ImageTransparentColor = System.Drawing.Color.Magenta; - this.btnImportFile.Name = "btnImportFile"; - this.btnImportFile.Size = new System.Drawing.Size(99, 22); - this.btnImportFile.Text = "Import Image"; - this.btnImportFile.Click += new System.EventHandler(this.btnImportFile_Click); - // - // btnSave - // - this.btnSave.Image = ((System.Drawing.Image)(resources.GetObject("btnSave.Image"))); - this.btnSave.ImageTransparentColor = System.Drawing.Color.Magenta; - this.btnSave.Name = "btnSave"; - this.btnSave.Size = new System.Drawing.Size(51, 22); - this.btnSave.Text = "Save"; - this.btnSave.Click += new System.EventHandler(this.btnSave_Click); - // - // btnSaveAs - // - this.btnSaveAs.Image = ((System.Drawing.Image)(resources.GetObject("btnSaveAs.Image"))); - this.btnSaveAs.ImageTransparentColor = System.Drawing.Color.Magenta; - this.btnSaveAs.Name = "btnSaveAs"; - this.btnSaveAs.Size = new System.Drawing.Size(76, 22); - this.btnSaveAs.Text = "Save As..."; - this.btnSaveAs.Click += new System.EventHandler(this.btnSaveAs_Click); - // - // btnUploadToDevice - // - this.btnUploadToDevice.Image = global::MagicPaint.Properties.Resources.device; - this.btnUploadToDevice.ImageTransparentColor = System.Drawing.Color.Magenta; - this.btnUploadToDevice.Name = "btnUploadToDevice"; - this.btnUploadToDevice.Size = new System.Drawing.Size(120, 22); - this.btnUploadToDevice.Text = "Upload To Device"; - this.btnUploadToDevice.Click += new System.EventHandler(this.btnUploadToDevice_Click); - // - // btnAbout - // - this.btnAbout.Image = global::MagicPaint.Properties.Resources.help_about; - this.btnAbout.ImageTransparentColor = System.Drawing.Color.Magenta; - this.btnAbout.Name = "btnAbout"; - this.btnAbout.Size = new System.Drawing.Size(60, 22); - this.btnAbout.Text = "About"; - this.btnAbout.Visible = false; - // // trackFrames // this.trackFrames.Location = new System.Drawing.Point(6, 48); @@ -212,6 +150,108 @@ private void InitializeComponent() this.pnlFrames.TabStop = false; this.pnlFrames.Text = "Frames"; // + // lblFrameNumber + // + this.lblFrameNumber.Location = new System.Drawing.Point(47, 19); + this.lblFrameNumber.Name = "lblFrameNumber"; + this.lblFrameNumber.Size = new System.Drawing.Size(106, 23); + this.lblFrameNumber.TabIndex = 7; + this.lblFrameNumber.Text = "0"; + this.lblFrameNumber.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // openFileDialog1 + // + this.openFileDialog1.FileName = "openFileDialog1"; + // + // panel1 + // + this.panel1.Controls.Add(this.btnToolFill); + this.panel1.Controls.Add(this.pnlCurrentColor); + this.panel1.Controls.Add(this.btnToolColorPicker); + this.panel1.Controls.Add(this.btnToolBrush); + this.panel1.Dock = System.Windows.Forms.DockStyle.Left; + this.panel1.Location = new System.Drawing.Point(0, 25); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(46, 604); + this.panel1.TabIndex = 6; + // + // btnToolFill + // + this.btnToolFill.Image = global::MagicPaint.Properties.Resources.fill_color; + this.btnToolFill.Location = new System.Drawing.Point(3, 95); + this.btnToolFill.Name = "btnToolFill"; + this.btnToolFill.Size = new System.Drawing.Size(40, 40); + this.btnToolFill.TabIndex = 3; + this.btnToolFill.UseVisualStyleBackColor = true; + this.btnToolFill.Click += new System.EventHandler(this.btnToolFill_Click); + // + // trackZoom + // + this.trackZoom.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.trackZoom.Location = new System.Drawing.Point(74, 590); + this.trackZoom.Maximum = 3000; + this.trackZoom.Minimum = 100; + this.trackZoom.Name = "trackZoom"; + this.trackZoom.Size = new System.Drawing.Size(732, 45); + this.trackZoom.TabIndex = 8; + this.trackZoom.TickFrequency = 10; + this.trackZoom.Value = 1600; + this.trackZoom.Scroll += new System.EventHandler(this.trackZoom_Scroll); + // + // groupBox2 + // + this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.groupBox2.Controls.Add(this.palette1); + this.groupBox2.Location = new System.Drawing.Point(812, 28); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(200, 168); + this.groupBox2.TabIndex = 10; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Palette"; + // + // pictureBox1 + // + this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image"))); + this.pictureBox1.Location = new System.Drawing.Point(56, 598); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(16, 16); + this.pictureBox1.TabIndex = 9; + this.pictureBox1.TabStop = false; + // + // pnlCurrentColor + // + this.pnlCurrentColor.BackColor = System.Drawing.Color.White; + this.pnlCurrentColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.pnlCurrentColor.Location = new System.Drawing.Point(3, 141); + this.pnlCurrentColor.Name = "pnlCurrentColor"; + this.pnlCurrentColor.Size = new System.Drawing.Size(40, 40); + this.pnlCurrentColor.TabIndex = 2; + this.pnlCurrentColor.TabStop = false; + this.pnlCurrentColor.Click += new System.EventHandler(this.pnlCurrentColor_Click); + // + // btnToolColorPicker + // + this.btnToolColorPicker.Image = global::MagicPaint.Properties.Resources.color_picker; + this.btnToolColorPicker.Location = new System.Drawing.Point(3, 49); + this.btnToolColorPicker.Name = "btnToolColorPicker"; + this.btnToolColorPicker.Size = new System.Drawing.Size(40, 40); + this.btnToolColorPicker.TabIndex = 1; + this.btnToolColorPicker.UseVisualStyleBackColor = true; + this.btnToolColorPicker.Click += new System.EventHandler(this.btnToolColorPicker_Click); + // + // btnToolBrush + // + this.btnToolBrush.BackColor = System.Drawing.SystemColors.Control; + this.btnToolBrush.Image = global::MagicPaint.Properties.Resources.draw_brush; + this.btnToolBrush.Location = new System.Drawing.Point(3, 3); + this.btnToolBrush.Name = "btnToolBrush"; + this.btnToolBrush.Size = new System.Drawing.Size(40, 40); + this.btnToolBrush.TabIndex = 0; + this.btnToolBrush.UseVisualStyleBackColor = false; + this.btnToolBrush.Click += new System.EventHandler(this.btnToolBrush_Click_1); + // // btnAddFrameFromImage // this.btnAddFrameFromImage.Image = global::MagicPaint.Properties.Resources.imageadd; @@ -262,15 +302,6 @@ private void InitializeComponent() this.btnSaveFrame.UseVisualStyleBackColor = true; this.btnSaveFrame.Click += new System.EventHandler(this.btnSaveFrame_Click); // - // lblFrameNumber - // - this.lblFrameNumber.Location = new System.Drawing.Point(47, 19); - this.lblFrameNumber.Name = "lblFrameNumber"; - this.lblFrameNumber.Size = new System.Drawing.Size(106, 23); - this.lblFrameNumber.TabIndex = 7; - this.lblFrameNumber.Text = "0"; - this.lblFrameNumber.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // // btnNextFrame // this.btnNextFrame.Image = global::MagicPaint.Properties.Resources.arrow_right; @@ -291,87 +322,68 @@ private void InitializeComponent() this.btnPreviousFrame.UseVisualStyleBackColor = true; this.btnPreviousFrame.Click += new System.EventHandler(this.btnPreviousFrame_Click); // - // openFileDialog1 - // - this.openFileDialog1.FileName = "openFileDialog1"; - // - // panel1 + // btnNew // - this.panel1.Controls.Add(this.pnlCurrentColor); - this.panel1.Controls.Add(this.btnToolColorPicker); - this.panel1.Controls.Add(this.btnToolBrush); - this.panel1.Dock = System.Windows.Forms.DockStyle.Left; - this.panel1.Location = new System.Drawing.Point(0, 25); - this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(46, 604); - this.panel1.TabIndex = 6; + this.btnNew.Image = global::MagicPaint.Properties.Resources.newdoc; + this.btnNew.ImageTransparentColor = System.Drawing.Color.Magenta; + this.btnNew.Name = "btnNew"; + this.btnNew.Size = new System.Drawing.Size(51, 22); + this.btnNew.Text = "New"; + this.btnNew.Click += new System.EventHandler(this.btnNew_Click); // - // pnlCurrentColor + // btnOpenFile // - this.pnlCurrentColor.BackColor = System.Drawing.Color.White; - this.pnlCurrentColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.pnlCurrentColor.Location = new System.Drawing.Point(3, 95); - this.pnlCurrentColor.Name = "pnlCurrentColor"; - this.pnlCurrentColor.Size = new System.Drawing.Size(40, 40); - this.pnlCurrentColor.TabIndex = 2; - this.pnlCurrentColor.TabStop = false; - this.pnlCurrentColor.Click += new System.EventHandler(this.pnlCurrentColor_Click); + this.btnOpenFile.Image = ((System.Drawing.Image)(resources.GetObject("btnOpenFile.Image"))); + this.btnOpenFile.ImageTransparentColor = System.Drawing.Color.Magenta; + this.btnOpenFile.Name = "btnOpenFile"; + this.btnOpenFile.Size = new System.Drawing.Size(56, 22); + this.btnOpenFile.Text = "Open"; + this.btnOpenFile.Click += new System.EventHandler(this.btnOpenFile_Click); // - // btnToolColorPicker + // btnImportFile // - this.btnToolColorPicker.Image = global::MagicPaint.Properties.Resources.color_picker; - this.btnToolColorPicker.Location = new System.Drawing.Point(3, 49); - this.btnToolColorPicker.Name = "btnToolColorPicker"; - this.btnToolColorPicker.Size = new System.Drawing.Size(40, 40); - this.btnToolColorPicker.TabIndex = 1; - this.btnToolColorPicker.UseVisualStyleBackColor = true; - this.btnToolColorPicker.Click += new System.EventHandler(this.btnToolColorPicker_Click); + this.btnImportFile.Image = ((System.Drawing.Image)(resources.GetObject("btnImportFile.Image"))); + this.btnImportFile.ImageTransparentColor = System.Drawing.Color.Magenta; + this.btnImportFile.Name = "btnImportFile"; + this.btnImportFile.Size = new System.Drawing.Size(99, 22); + this.btnImportFile.Text = "Import Image"; + this.btnImportFile.Click += new System.EventHandler(this.btnImportFile_Click); // - // btnToolBrush + // btnSave // - this.btnToolBrush.BackColor = System.Drawing.SystemColors.Control; - this.btnToolBrush.Image = global::MagicPaint.Properties.Resources.draw_brush; - this.btnToolBrush.Location = new System.Drawing.Point(3, 3); - this.btnToolBrush.Name = "btnToolBrush"; - this.btnToolBrush.Size = new System.Drawing.Size(40, 40); - this.btnToolBrush.TabIndex = 0; - this.btnToolBrush.UseVisualStyleBackColor = false; - this.btnToolBrush.Click += new System.EventHandler(this.btnToolBrush_Click_1); + this.btnSave.Image = ((System.Drawing.Image)(resources.GetObject("btnSave.Image"))); + this.btnSave.ImageTransparentColor = System.Drawing.Color.Magenta; + this.btnSave.Name = "btnSave"; + this.btnSave.Size = new System.Drawing.Size(51, 22); + this.btnSave.Text = "Save"; + this.btnSave.Click += new System.EventHandler(this.btnSave_Click); // - // trackZoom + // btnSaveAs // - this.trackZoom.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.trackZoom.Location = new System.Drawing.Point(74, 590); - this.trackZoom.Maximum = 3000; - this.trackZoom.Minimum = 100; - this.trackZoom.Name = "trackZoom"; - this.trackZoom.Size = new System.Drawing.Size(732, 45); - this.trackZoom.TabIndex = 8; - this.trackZoom.TickFrequency = 10; - this.trackZoom.Value = 1600; - this.trackZoom.Scroll += new System.EventHandler(this.trackZoom_Scroll); + this.btnSaveAs.Image = ((System.Drawing.Image)(resources.GetObject("btnSaveAs.Image"))); + this.btnSaveAs.ImageTransparentColor = System.Drawing.Color.Magenta; + this.btnSaveAs.Name = "btnSaveAs"; + this.btnSaveAs.Size = new System.Drawing.Size(76, 22); + this.btnSaveAs.Text = "Save As..."; + this.btnSaveAs.Click += new System.EventHandler(this.btnSaveAs_Click); // - // pictureBox1 + // btnUploadToDevice // - this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image"))); - this.pictureBox1.Location = new System.Drawing.Point(56, 598); - this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(16, 16); - this.pictureBox1.TabIndex = 9; - this.pictureBox1.TabStop = false; + this.btnUploadToDevice.Image = global::MagicPaint.Properties.Resources.device; + this.btnUploadToDevice.ImageTransparentColor = System.Drawing.Color.Magenta; + this.btnUploadToDevice.Name = "btnUploadToDevice"; + this.btnUploadToDevice.Size = new System.Drawing.Size(120, 22); + this.btnUploadToDevice.Text = "Upload To Device"; + this.btnUploadToDevice.Click += new System.EventHandler(this.btnUploadToDevice_Click); // - // groupBox2 + // btnAbout // - this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.groupBox2.Controls.Add(this.palette1); - this.groupBox2.Location = new System.Drawing.Point(812, 28); - this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(200, 168); - this.groupBox2.TabIndex = 10; - this.groupBox2.TabStop = false; - this.groupBox2.Text = "Palette"; + this.btnAbout.Image = global::MagicPaint.Properties.Resources.help_about; + this.btnAbout.ImageTransparentColor = System.Drawing.Color.Magenta; + this.btnAbout.Name = "btnAbout"; + this.btnAbout.Size = new System.Drawing.Size(60, 22); + this.btnAbout.Text = "About"; + this.btnAbout.Visible = false; // // palette1 // @@ -424,10 +436,10 @@ private void InitializeComponent() this.pnlFrames.ResumeLayout(false); this.pnlFrames.PerformLayout(); this.panel1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.pnlCurrentColor)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.trackZoom)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.groupBox2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pnlCurrentColor)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -469,6 +481,7 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripButton btnAbout; private System.Windows.Forms.GroupBox groupBox2; private Palette palette1; + private System.Windows.Forms.Button btnToolFill; } } diff --git a/MagicPaint/Form1.cs b/MagicPaint/Form1.cs index 0a9abfb..6031ef3 100644 --- a/MagicPaint/Form1.cs +++ b/MagicPaint/Form1.cs @@ -122,6 +122,11 @@ private void btnToolBrush_Click_1(object sender, EventArgs e) SetCurrentTool(MagicPixler.Tool.Brush); } + private void btnToolFill_Click(object sender, EventArgs e) + { + SetCurrentTool(MagicPixler.Tool.Fill); + } + private void pnlCurrentColor_Click(object sender, EventArgs e) { colorDialog1.FullOpen = true; @@ -344,6 +349,7 @@ private void SetCurrentTool(MagicPixler.Tool tool) { btnToolBrush.Enabled = true; btnToolColorPicker.Enabled = true; + btnToolFill.Enabled = true; switch (tool) { case MagicPixler.Tool.Brush: @@ -352,6 +358,9 @@ private void SetCurrentTool(MagicPixler.Tool tool) case MagicPixler.Tool.ColorPicker: btnToolColorPicker.Enabled = false; break; + case MagicPixler.Tool.Fill: + btnToolFill.Enabled = false; + break; } magicPixler1.CurrentTool = tool; } @@ -433,5 +442,6 @@ private void SetZoomLevel(int percent) { magicPixler1.PixelSize = (int)Math.Round(1.0 / 100.0 * percent, 0); } + } } diff --git a/MagicPaint/Form1.resx b/MagicPaint/Form1.resx index 41a5cb4..b5be740 100644 --- a/MagicPaint/Form1.resx +++ b/MagicPaint/Form1.resx @@ -187,7 +187,7 @@ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO - vgAADr4B6kKxwAAAAghJREFUOE+t00lvEnEYx/HnXTS1RaCUtam2pXQRK7TWEjWtqVuFqnF9CSS8BcuF + vAAADrwBlbxySQAAAghJREFUOE+t00lvEnEYx/HnXTS1RaCUtam2pXQRK7TWEjWtqVuFqnF9CSS8BcuF K4lK9cKNiw1L7FtASBAOtnowsbhRys6w+PP/jJMUEi81TvLJf2byfCeTzH/ovxwul6u4fHEZb3YSfXai 7C2i8V3EEruICwmBZ7lRcqIl5yI8bjdK1RaOevB1udZCpd5GrdlBQ+pAanfx9PETcKPkRM4LDjx68BBS q4vn0VSfFyyWwstYGqF4Gt3uL3mWGyUnWji/gPt376Hd6aIptSEJvLJGs4Vao4VqXUK52kRZrDzLjZIT @@ -208,26 +208,6 @@ 488, 17 - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xh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toamiqB6ZLVUubJRo8E3Sl0XqnU4GTrcWaDHnUVa3FneMYNX3k9mqUJCLgd1czI9 + bhc11ZWMiIz2tueNpkxUbrlZorQEFg2b/XP6TCffiYwn8iULp0snrZc+yxxZUfQkA+2DyDtBIZp3MoPF + heKuJXbpqJXCmV4JKhvBzhb0Gv2y2wxHmIMLp7pMthvsQVvVnfBbatLj9Q5IZNIBDrt1YjxTgKVVqVdD + KsctFxjdc36vatQHB2ftVwaMkBuflGENuhrsn8CUeScgoTHEkJudKox+USxPabG9rdNsUvowCJMuA/WL + zMKkPU2ypr15raAlptwk+70S/DqEVsDuyJhY2o2w0Knb0XRb5MNE893oWHtYaLDg3DW6n2JMbuNx6+FB + VvPfCeIL+reKUfkq3y1lLewPvJe5m94PuxAAn8i8SV/qA3qAdkYD5eUf8cDzRw88zmkiWxGE6lqO2AZw + PkHdQxKY7j8tAZW6tVC8pfHoMLx8lUpdnJ+FXLSMrPmER9whlwlgT7x7OX59338pydVkMZiMesh4mz7m + Kbn5vRz/YTv1x5bW1dU1dPd06REEQX4CcfkB+/p+LtUAAAAASUVORK5CYII= diff --git a/MagicPaint/MagicPaint.csproj b/MagicPaint/MagicPaint.csproj index 6b8fcee..3449ac8 100644 --- a/MagicPaint/MagicPaint.csproj +++ b/MagicPaint/MagicPaint.csproj @@ -30,6 +30,7 @@ TRACE prompt 4 + true icon.ico @@ -47,6 +48,7 @@ + Form @@ -180,6 +182,7 @@ +