昨日、ロジックについて質問しました。それ以外の場合はエラーです。しかし、私がこれを行うときは?int、そのエラー..。
private static void mergeimagefile(string image1path, string image2path)
{
//get all the files in a directory
string jpg1 = @image1path;
string jpg2 = @image2path;
string jpg3 = @image2path;
Image img1 = Image.FromFile(jpg1);
Image img2 = Image.FromFile(jpg2);
//int width = img1.Width + img2.Width;
int width = 640;
//int height = Math.Max(img1.Height, img2.Height);
int height = 360;
int w;
if (img2.Width > 640) {
w = 640;
}
else if (img2.Width <= 640)
{
w = ((width - img2.Width) / 2);
}
System.Windows.Forms.MessageBox.Show(w.ToString());
int h = new int();
if (img2.Height > 360)
{
h = 360;
}
else if (img2.Height <= 360)
{
h = (height - img2.Height) / 2;
}
Bitmap img3 = new Bitmap(width, height);
Graphics g = Graphics.FromImage(img3);
g.Clear(Color.Black);
g.DrawImage(img1, new Point(0, 0));
//ERROR IN HERE
g.DrawImage(img2, new Point(w, h));
g.Dispose();
img1.Dispose();
img2.Dispose();
img3.Save(jpg3, System.Drawing.Imaging.ImageFormat.Jpeg);
img3.Dispose();
}
、、を追加してみましたが、int?
このMsdnマニュアルint w = null;
によると、それでもエラーが発生しますか?
エラー1割り当てられていないローカル変数'w'の使用C:\ Documents and Settings \ admin \ My Documents \ Visual Studio 2008 \ Projects \ template \ template \ Form1.cs6850テンプレート
これを正しくする方法は?