文章力が足りず意味の分からない部分があるかもしれません。そういった場合にも気軽にお答えください。なるべく早く返信したいと思います。
以下質問内容
(目標)
Form1の中にはピクチャーボックス(以下pb)が2つあります。
片方のpb1には処理前の画像を、もう一方のpb2には画像処理後の画像を表示するプログラムを完成させたい。
(方法)
書籍に書いてあるプログラムをPC上で実行させる。(Visualstadio2010)
(問題点)
・エラーにより実行ができない(エラーの内容は以下)
'System.Windows.Forms.PictureBox' に 'bmp' の定義が含まれておらず、型 'System.Windows.Forms.PictureBox' の最初の引数を受け付ける拡張メソッドが見つかりませんでした。using ディレクティブまたはアセンブリ参照が不足しています。
・プログラム中の"pb1.bmp"は自分で用意する必要があるのか
・ 書籍に掲載されていた部分は、「 26行 : int i, j, nx, ny, gray; ~ 41行 : pb2.bmp = bmp; 」である。
そもそもこのプログラムを記述する場所が正しいのかどうか疑わしい
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace SampleProgram2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void pb2_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
int i, j, nx, ny, gray;
Color col;
nx = pb1.Width;
nx = pb1.Height;
Bitmap bmp = new Bitmap(pb1.bmp);
for (j = 0; j < ny; j++)
{
for (i = 0; i < nx; i++)
{
col = bmp.GetPixel(i, j);
gray = col.R;
bmp.SetPixel(i, j, Color.FromArgb(gray, gray, gray));
}
}
pb2.bmp = bmp;
}
private void pb1_Click(object sender, EventArgs e)
{
}
}
}