/// <summary> /// 特定フォルダに保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonSave_Click(object sender, EventArgs e) { Bitmap bmp = (Bitmap)pictureBox1.Image; if (bmp == null) { return; } buttonSave.Enabled = false; if (savedBmp != null) { if (BitmapUtil.Compare(bmp, savedBmp) == true) { return; } } // savedBmp = new Bitmap(bmp); ImageFormat fmt = ImageFormat.Bmp; if (radioButton1.Checked) { fmt = ImageFormat.Bmp; } if (radioButton2.Checked) { fmt = ImageFormat.Jpeg; } if (radioButton3.Checked) { fmt = ImageFormat.Png; } string fname = MakeFileName(fmt); if (fname != "") { bmp.Save(fname, fmt); textBox1.Text = "[img " + Path.GetFileName(fname) + "]"; } else { textBox1.Text = "[error] Error could not access the output directory"; } }
/// <summary> /// クリップボードから取り込み /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonClip_Click(object sender, EventArgs e) { var clip = Clipboard.GetDataObject(); // 画像ファイルのみ取り込み var bmp = clip.GetData(typeof(Bitmap)) as Bitmap; if (bmp == null) { return; } // ピクチャへ表示 bool isImgUpdaed = true; if (pictureBox1.Image == null) {//初回取り込み pictureBox1.Image = bmp; } else { //2回目以降 if (BitmapUtil.Compare(bmp, (Bitmap)pictureBox1.Image) == false) { //更新あり pictureBox1.Image = bmp; if (savedBmp != null) { if (BitmapUtil.Compare(bmp, savedBmp) == true) { isImgUpdaed = false; } } } } buttonSave.Enabled = isImgUpdaed; }