📄 pixeldisplaydialog.cs
字号:
//
this.columnHeader7.Text = "x5";
this.columnHeader7.Width = 40;
//
// columnHeader8
//
this.columnHeader8.Text = "x6";
this.columnHeader8.Width = 40;
//
// columnHeader9
//
this.columnHeader9.Text = "x7";
this.columnHeader9.Width = 40;
//
// radioButton1
//
this.radioButton1.Location = new System.Drawing.Point(16, 16);
this.radioButton1.Name = "radioButton1";
this.radioButton1.TabIndex = 8;
this.radioButton1.Text = "Red";
this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
//
// radioButton2
//
this.radioButton2.Location = new System.Drawing.Point(16, 48);
this.radioButton2.Name = "radioButton2";
this.radioButton2.TabIndex = 9;
this.radioButton2.Text = "Green";
this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
//
// radioButton3
//
this.radioButton3.Location = new System.Drawing.Point(16, 80);
this.radioButton3.Name = "radioButton3";
this.radioButton3.TabIndex = 10;
this.radioButton3.Text = "Blue";
this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButton3_CheckedChanged);
//
// ColorComponent
//
this.ColorComponent.Controls.AddRange(new System.Windows.Forms.Control[] {
this.radioButton3,
this.radioButton2,
this.radioButton1});
this.ColorComponent.Location = new System.Drawing.Point(16, 272);
this.ColorComponent.Name = "ColorComponent";
this.ColorComponent.Size = new System.Drawing.Size(128, 112);
this.ColorComponent.TabIndex = 11;
this.ColorComponent.TabStop = false;
this.ColorComponent.Text = "Color Component";
//
// groupBox1
//
this.groupBox1.Location = new System.Drawing.Point(16, 272);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(144, 112);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
//
// groupBox2
//
this.groupBox2.Controls.AddRange(new System.Windows.Forms.Control[] {
this.radioButton7,
this.radioButton6,
this.radioButton5,
this.radioButton4});
this.groupBox2.Location = new System.Drawing.Point(16, 152);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(128, 112);
this.groupBox2.TabIndex = 12;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Quadrant";
//
// radioButton7
//
this.radioButton7.Location = new System.Drawing.Point(64, 64);
this.radioButton7.Name = "radioButton7";
this.radioButton7.Size = new System.Drawing.Size(56, 32);
this.radioButton7.TabIndex = 3;
this.radioButton7.Text = "Lower Right";
this.radioButton7.CheckedChanged += new System.EventHandler(this.radioButton7_CheckedChanged);
//
// radioButton6
//
this.radioButton6.Location = new System.Drawing.Point(16, 64);
this.radioButton6.Name = "radioButton6";
this.radioButton6.Size = new System.Drawing.Size(56, 32);
this.radioButton6.TabIndex = 2;
this.radioButton6.Text = "Lower Left";
this.radioButton6.CheckedChanged += new System.EventHandler(this.radioButton6_CheckedChanged);
//
// radioButton5
//
this.radioButton5.Location = new System.Drawing.Point(64, 16);
this.radioButton5.Name = "radioButton5";
this.radioButton5.Size = new System.Drawing.Size(56, 32);
this.radioButton5.TabIndex = 1;
this.radioButton5.Text = "Upper Right";
this.radioButton5.CheckedChanged += new System.EventHandler(this.radioButton5_CheckedChanged);
//
// radioButton4
//
this.radioButton4.Location = new System.Drawing.Point(16, 16);
this.radioButton4.Name = "radioButton4";
this.radioButton4.Size = new System.Drawing.Size(56, 32);
this.radioButton4.TabIndex = 0;
this.radioButton4.Text = "Upper Left";
this.radioButton4.CheckedChanged += new System.EventHandler(this.radioButton4_CheckedChanged);
//
// PixelDisplayDialog
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(552, 389);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.groupBox2,
this.ColorComponent,
this.listView1,
this.button5,
this.button4,
this.pictureBox1});
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "PixelDisplayDialog";
this.Text = "PixelDisplayDialog";
this.ColorComponent.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void button5_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void button4_Click(object sender, System.EventArgs e)
{
// Convert RGB into YPrPb format and display in new dialog
YUVDisplayDialog dlg = new YUVDisplayDialog((Bitmap) pictureBox1.Image);
dlg.ShowDialog();
}
private void listView1_SelectedIndexChanged(object sender, System.EventArgs e)
{}
private void radioButton1_CheckedChanged(object sender, System.EventArgs e)
{
// Select Red component and write to ListView
componentColor = Color.Red;
fillLV();
}
private void radioButton2_CheckedChanged(object sender, System.EventArgs e)
{
// Select Green component and write to ListView
componentColor = Color.Green;
fillLV();
}
private void radioButton3_CheckedChanged(object sender, System.EventArgs e)
{
// Select Blue component and write to ListView
componentColor = Color.Blue;
fillLV();
}
private void radioButton4_CheckedChanged(object sender, System.EventArgs e)
{
// Select Upper Left quadrant and write to ListView
quadX = 0;
quadY = 0;
fillLV();
}
private void radioButton5_CheckedChanged(object sender, System.EventArgs e)
{
// Select Upper Right quadrant and write to ListView
quadX = 8;
quadY = 0;
fillLV();
}
private void radioButton6_CheckedChanged(object sender, System.EventArgs e)
{
// Select Lower Left quadrant and write to ListView
quadX = 0;
quadY = 8;
fillLV();
}
private void radioButton7_CheckedChanged(object sender, System.EventArgs e)
{
// Select Lower Right quadrant and write to ListView
quadX = 8;
quadY = 8;
fillLV();
}
private void fillLV()
{
// Write selected quadrant and color component to ListViwe
int i, j;
string[] rowRGB = new string[9];
byte pixelColor;
Bitmap img = new Bitmap(pictureBox1.Image);
listView1.Items.Clear();
listView1.ForeColor = componentColor;
for (i=quadY; i<quadY+8; i++)
{
rowRGB[0] = "y" + i.ToString();
for (j=quadX; j<quadX+8; j++)
{
if (componentColor == Color.Red)
pixelColor = img.GetPixel(j,i).R;
else if (componentColor == Color.Green)
pixelColor = img.GetPixel(j,i).G;
else
pixelColor = img.GetPixel(j,i).B;
rowRGB[j-quadX+1] = pixelColor.ToString();
}
listView1.Items.Add(new ListViewItem(rowRGB));
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -