
前田稔(Maeda Minoru)の超初心者のプログラム入門
![]()
![]()
| 青色(B)の8ビット | 緑色(G)の8ビット | 赤色(R)の8ビット |
private void MyHandler(object sender, PaintEventArgs e)
{
Graphics g;
string str;
g = e.Graphics;
if (App.bmp == null) Application.Exit();
App.View(g,0,0);
if (xp==0) MessageBox.Show("抽出する色を選択して下さい");
else
{
str = "v:" + val + " [" + xp + "," + yp + "]";
this.Text = str;
}
}
|
int xp=0, yp=0;
int val= 30;
private void OnMyMouseDown(object sender, MouseEventArgs e)
{ if (e.Button == MouseButtons.Left) //マウスの左ボタン
{ if (xp==0)
{ xp= e.X;
yp= e.Y;
}
else
{ App.LoadImage();
val+= 4;
App.Sel_Color(xp,yp,val);
}
}
if (e.Button == MouseButtons.Right) //マウスの右ボタン
{ App.LoadImage();
xp= 0;
val= 30;
}
Invalidate();
}
|
public Color cor_L; //対象となる Color の範囲
public Color cor_H;
|
// 画像から xp,yp で指定された色を抽出する関数
public void Sel_Color(int xp, int yp, int wd)
{ if (bmp == null) return;
SetLimit(xp,yp,wd);
for(int y=0; y<bmp.Height; y++)
for(int x=0; x<bmp.Width; x++)
{ if (ChkPic(x,y)==false) bmp.SetPixel(x,y,Color.Black); }
}
|
![]()
[Next Chapter ↓] Color ⇒ エッジ画像
[Previous Chapter ↑] Delete Color