我不断收到异常消息
值不能为空参数名称:编码器
这似乎是由行开始
触发的“图片Box3.Image.Save(ms ....”等
我使用pictureBox3来保存裁剪的位图,我想把它放到DataGridView1中,还有一些注释和参考。有没有人对我遇到这些问题有什么建议。非常感谢Steve
private void btnsavenote_click(object sender, EventArgs e)
{
if (panel3.BackgroundImage != null)
{
try
{
// crop showimagefn.Text at xloc, yloc ,708,530
Image croparea = Image.FromFile(showimagefn.Text);
Bitmap croppedBitmap = new Bitmap(croparea);
croppedBitmap = croppedBitmap.Clone (new Rectangle(((-xloc) - (708 / 2)), ((-yloc) - (530 / 2)), 708, 530), System.Drawing.Imaging.PixelFormat.Format24bppRgb); //
pictureBox3.Visible = true;
pictureBox3.Image = croppedBitmap;
MemoryStream ms = new MemoryStream();
pictureBox3.Image.Save(ms, pictureBox3.Image.RawFormat);
byte[] imgbyte = ms.ToArray();
dataGridView1.Rows.Add(surveyreportRef, (this.insertnote.Text), imgbyte); //
surveyreportRef++;
croppedBitmap.Dispose();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}