내가 건축 c#contact 관리자는 바탕 화면 응용 프로그램을 선택할 수 있는 아바타에서 이미지 파일 이후 작물니다. 원본 이미지가 제대로 표시된 후 자르기,대체 원래 하나입니다. 그러나 나중에는 그에 따라 등록하려고 시도는 계정의 이미지가 나타나 Null 이 될 수 있기와 같은 오류가 표시됩니다.
시스템입니다.ArgumentNullException:"값은 null 이 될 수 없습니다. (매개변수 'encoder')"
는 방법에 대한 이미지를 업로드 등록 페이지:
private void button_browse_Click(object sender, EventArgs e)
{
// select and display image in the picturebox
OpenFileDialog opf = new OpenFileDialog();
opf.Filter = "Select Image(*.jpg;*.png;*.gif)|*.jpg;*.png;*.gif";
if(opf.ShowDialog() == DialogResult.OK)
{
pictureBoxProfileImage.Image = Image.FromFile(opf.FileName);
setImage(pictureBoxProfileImage.Image);
}
}
는 방법에 대한 이미지가 잘:
private void button_Select_Cropped_Area_Click(object sender, EventArgs e)
{
Cursor = Cursors.Default;
Bitmap bitmap2 = new Bitmap(pictureBoxProfileImage.Width, pictureBoxProfileImage.Height);
pictureBoxProfileImage.DrawToBitmap(bitmap2, pictureBoxProfileImage.ClientRectangle);
Bitmap croppedImage = new Bitmap(rectW, rectH);
for (int x = 0; x < rectW; x++)
{
for (int y = 0; y < rectH; y++)
{
Color pxlColor = bitmap2.GetPixel(cropX + x, cropY + y);
croppedImage.SetPixel(x, y, pxlColor);
}
}
pictureBoxProfileImage.Image.Dispose();
pictureBoxProfileImage.Image = (Image)croppedImage;
pictureBoxProfileImage.SizeMode = PictureBoxSizeMode.StretchImage;
}
여기에 라인에 오류가 발생하고 이미지를 저장할 때:
MemoryStream picture = new MemoryStream();
pictureBoxProfileImage.Image.Save(picture, pictureBoxProfileImage.Image.RawFormat);
그것은 언급 할 가치가있는 등록이 제대로 작동하는 경우 원본 이미지는 허용되지 않습니다. 어야 나는 그들을 대체 어떻게 든(덮어 원래 하나로 자른 하나는)?