Click here to Skip to main content
15,886,873 members
Articles / Programming Languages / C#

Managed Bitmaps 2

Rate me:
Please Sign up or sign in to vote.
4.77/5 (17 votes)
19 Mar 2010CPOL5 min read 51.5K   991   36  
This article presents classes that represent bitmaps in full managed code.
namespace PfzDrawingSample
{
	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.panel1 = new System.Windows.Forms.Panel();
			this.numericUpDownBlue = new System.Windows.Forms.NumericUpDown();
			this.numericUpDownGreen = new System.Windows.Forms.NumericUpDown();
			this.numericUpDownRed = new System.Windows.Forms.NumericUpDown();
			this.buttonSave = new System.Windows.Forms.Button();
			this.comboMethod = new System.Windows.Forms.ComboBox();
			this.label4 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.trackBarBlue = new System.Windows.Forms.TrackBar();
			this.label2 = new System.Windows.Forms.Label();
			this.trackBarGreen = new System.Windows.Forms.TrackBar();
			this.label1 = new System.Windows.Forms.Label();
			this.trackBarRed = new System.Windows.Forms.TrackBar();
			this.buttonLoad = new System.Windows.Forms.Button();
			this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
			this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
			this.panel1.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.numericUpDownBlue)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.numericUpDownGreen)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.numericUpDownRed)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.trackBarBlue)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.trackBarGreen)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.trackBarRed)).BeginInit();
			this.SuspendLayout();
			// 
			// panel1
			// 
			this.panel1.Controls.Add(this.numericUpDownBlue);
			this.panel1.Controls.Add(this.numericUpDownGreen);
			this.panel1.Controls.Add(this.numericUpDownRed);
			this.panel1.Controls.Add(this.buttonSave);
			this.panel1.Controls.Add(this.comboMethod);
			this.panel1.Controls.Add(this.label4);
			this.panel1.Controls.Add(this.label3);
			this.panel1.Controls.Add(this.trackBarBlue);
			this.panel1.Controls.Add(this.label2);
			this.panel1.Controls.Add(this.trackBarGreen);
			this.panel1.Controls.Add(this.label1);
			this.panel1.Controls.Add(this.trackBarRed);
			this.panel1.Controls.Add(this.buttonLoad);
			this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
			this.panel1.Location = new System.Drawing.Point(0, 337);
			this.panel1.Name = "panel1";
			this.panel1.Size = new System.Drawing.Size(803, 165);
			this.panel1.TabIndex = 0;
			// 
			// numericUpDownBlue
			// 
			this.numericUpDownBlue.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
			this.numericUpDownBlue.Location = new System.Drawing.Point(714, 115);
			this.numericUpDownBlue.Maximum = new decimal(new int[] {
            255,
            0,
            0,
            0});
			this.numericUpDownBlue.Minimum = new decimal(new int[] {
            255,
            0,
            0,
            -2147483648});
			this.numericUpDownBlue.Name = "numericUpDownBlue";
			this.numericUpDownBlue.Size = new System.Drawing.Size(77, 20);
			this.numericUpDownBlue.TabIndex = 13;
			this.numericUpDownBlue.ValueChanged += new System.EventHandler(this.numericUpDownBlue_ValueChanged);
			// 
			// numericUpDownGreen
			// 
			this.numericUpDownGreen.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
			this.numericUpDownGreen.Location = new System.Drawing.Point(713, 64);
			this.numericUpDownGreen.Maximum = new decimal(new int[] {
            255,
            0,
            0,
            0});
			this.numericUpDownGreen.Minimum = new decimal(new int[] {
            255,
            0,
            0,
            -2147483648});
			this.numericUpDownGreen.Name = "numericUpDownGreen";
			this.numericUpDownGreen.Size = new System.Drawing.Size(77, 20);
			this.numericUpDownGreen.TabIndex = 12;
			this.numericUpDownGreen.ValueChanged += new System.EventHandler(this.numericUpDownGreen_ValueChanged);
			// 
			// numericUpDownRed
			// 
			this.numericUpDownRed.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
			this.numericUpDownRed.Location = new System.Drawing.Point(714, 13);
			this.numericUpDownRed.Maximum = new decimal(new int[] {
            255,
            0,
            0,
            0});
			this.numericUpDownRed.Minimum = new decimal(new int[] {
            255,
            0,
            0,
            -2147483648});
			this.numericUpDownRed.Name = "numericUpDownRed";
			this.numericUpDownRed.Size = new System.Drawing.Size(77, 20);
			this.numericUpDownRed.TabIndex = 11;
			this.numericUpDownRed.ValueChanged += new System.EventHandler(this.numericUpDownRed_ValueChanged);
			// 
			// buttonSave
			// 
			this.buttonSave.Location = new System.Drawing.Point(12, 115);
			this.buttonSave.Name = "buttonSave";
			this.buttonSave.Size = new System.Drawing.Size(75, 23);
			this.buttonSave.TabIndex = 10;
			this.buttonSave.Text = "Save";
			this.buttonSave.UseVisualStyleBackColor = true;
			this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
			// 
			// comboMethod
			// 
			this.comboMethod.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.comboMethod.FormattingEnabled = true;
			this.comboMethod.Items.AddRange(new object[] {
            "Pfz.Drawing (Lock)",
            "Pfz.Drawing (ManagedBitmap)",
            "Get/SetPixel",
            "Unsafe"});
			this.comboMethod.Location = new System.Drawing.Point(12, 64);
			this.comboMethod.Name = "comboMethod";
			this.comboMethod.Size = new System.Drawing.Size(172, 21);
			this.comboMethod.TabIndex = 9;
			// 
			// label4
			// 
			this.label4.AutoSize = true;
			this.label4.Location = new System.Drawing.Point(12, 48);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(43, 13);
			this.label4.TabIndex = 8;
			this.label4.Text = "Method";
			// 
			// label3
			// 
			this.label3.AutoSize = true;
			this.label3.Location = new System.Drawing.Point(198, 115);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(28, 13);
			this.label3.TabIndex = 7;
			this.label3.Text = "Blue";
			// 
			// trackBarBlue
			// 
			this.trackBarBlue.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
						| System.Windows.Forms.AnchorStyles.Right)));
			this.trackBarBlue.Location = new System.Drawing.Point(232, 115);
			this.trackBarBlue.Maximum = 255;
			this.trackBarBlue.Minimum = -255;
			this.trackBarBlue.Name = "trackBarBlue";
			this.trackBarBlue.Size = new System.Drawing.Size(476, 45);
			this.trackBarBlue.TabIndex = 6;
			this.trackBarBlue.Scroll += new System.EventHandler(this.trackBarBlue_Scroll);
			// 
			// label2
			// 
			this.label2.AutoSize = true;
			this.label2.Location = new System.Drawing.Point(190, 64);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(36, 13);
			this.label2.TabIndex = 5;
			this.label2.Text = "Green";
			// 
			// trackBarGreen
			// 
			this.trackBarGreen.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
						| System.Windows.Forms.AnchorStyles.Right)));
			this.trackBarGreen.Location = new System.Drawing.Point(232, 64);
			this.trackBarGreen.Maximum = 255;
			this.trackBarGreen.Minimum = -255;
			this.trackBarGreen.Name = "trackBarGreen";
			this.trackBarGreen.Size = new System.Drawing.Size(476, 45);
			this.trackBarGreen.TabIndex = 4;
			this.trackBarGreen.Scroll += new System.EventHandler(this.trackBarGreen_Scroll);
			// 
			// label1
			// 
			this.label1.AutoSize = true;
			this.label1.Location = new System.Drawing.Point(199, 18);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(27, 13);
			this.label1.TabIndex = 3;
			this.label1.Text = "Red";
			// 
			// trackBarRed
			// 
			this.trackBarRed.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
						| System.Windows.Forms.AnchorStyles.Right)));
			this.trackBarRed.Location = new System.Drawing.Point(232, 13);
			this.trackBarRed.Maximum = 255;
			this.trackBarRed.Minimum = -255;
			this.trackBarRed.Name = "trackBarRed";
			this.trackBarRed.Size = new System.Drawing.Size(476, 45);
			this.trackBarRed.TabIndex = 2;
			this.trackBarRed.ValueChanged += new System.EventHandler(this.trackBarRed_ValueChanged);
			// 
			// buttonLoad
			// 
			this.buttonLoad.Location = new System.Drawing.Point(12, 13);
			this.buttonLoad.Name = "buttonLoad";
			this.buttonLoad.Size = new System.Drawing.Size(75, 23);
			this.buttonLoad.TabIndex = 0;
			this.buttonLoad.Text = "Load";
			this.buttonLoad.UseVisualStyleBackColor = true;
			this.buttonLoad.Click += new System.EventHandler(this.buttonLoad_Click);
			// 
			// openFileDialog
			// 
			this.openFileDialog.FileName = "openFileDialog1";
			// 
			// Form1
			// 
			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			this.ClientSize = new System.Drawing.Size(803, 502);
			this.Controls.Add(this.panel1);
			this.Name = "Form1";
			this.Text = "Form1";
			this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
			this.panel1.ResumeLayout(false);
			this.panel1.PerformLayout();
			((System.ComponentModel.ISupportInitialize)(this.numericUpDownBlue)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.numericUpDownGreen)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.numericUpDownRed)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.trackBarBlue)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.trackBarGreen)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.trackBarRed)).EndInit();
			this.ResumeLayout(false);

		}

		#endregion

		private System.Windows.Forms.Panel panel1;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.TrackBar trackBarBlue;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.TrackBar trackBarGreen;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.TrackBar trackBarRed;
		private System.Windows.Forms.Button buttonLoad;
		private System.Windows.Forms.SaveFileDialog saveFileDialog;
		private System.Windows.Forms.OpenFileDialog openFileDialog;
		private System.Windows.Forms.ComboBox comboMethod;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Button buttonSave;
		private System.Windows.Forms.NumericUpDown numericUpDownBlue;
		private System.Windows.Forms.NumericUpDown numericUpDownGreen;
		private System.Windows.Forms.NumericUpDown numericUpDownRed;
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Microsoft
United States United States
I started to program computers when I was 11 years old, as a hobbyist, programming in AMOS Basic and Blitz Basic for Amiga.
At 12 I had my first try with assembler, but it was too difficult at the time. Then, in the same year, I learned C and, after learning C, I was finally able to learn assembler (for Motorola 680x0).
Not sure, but probably between 12 and 13, I started to learn C++. I always programmed "in an object oriented way", but using function pointers instead of virtual methods.

At 15 I started to learn Pascal at school and to use Delphi. At 16 I started my first internship (using Delphi). At 18 I started to work professionally using C++ and since then I've developed my programming skills as a professional developer in C++ and C#, generally creating libraries that help other developers do their work easier, faster and with less errors.

Want more info or simply want to contact me?
Take a look at: http://paulozemek.azurewebsites.net/
Or e-mail me at: paulozemek@outlook.com

Codeproject MVP 2012, 2015 & 2016
Microsoft MVP 2013-2014 (in October 2014 I started working at Microsoft, so I can't be a Microsoft MVP anymore).

Comments and Discussions