ฉันเป็นตึก c#ติดต่อผู้จัดการพื้นที่ทำงานโปรแกรมที่คุณสามารถเลือกเป็นร่างอวตารของภาพจากแฟ้มหลังจากข้าวโพดไปส่วนหนึ่งมัน ภาพต้นฉบับสำหรับคืออย่างเหมาะสจะถูกแสดงหลังจาก cropping และเข้าแทนที่ดั้งเดิมหนึ่ง อย่างไรก็ตามทีหลัง,อัพยายามจะลงทะเบียนในบัญชีผู้ใช้ภาพดูเหมือนจะเป็นโพรโทคอล aimcomment อย่างนั้นข้อผิดพลาดเกิดขึ้นระหว่างการแสดง:
ระบบArgumentNullException:"ค่าไม่สามารถเป็นโพรโทคอล aimcomment. (พารามิเตอร์ 'ตัวเข้ารหัส')"
จากวิธีการเพื่อทำการอัปโหลดภาพไปที่ลงทะเบียนหน้า:
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);
มันคุ้มที่จะพูดถึงเรื่องนั้นเครื่องบันทึกใช้งานได้เหมาะสมหากภาพต้นฉบับสำหรับกำลังผ่านพ้นไปแล้ว ฉันควรจะแทนที่พวกเขาว่า(องการจะเขียนทับหรือไม่ดั้งเดิมคนหนึ่ง cropped หนึ่ง)?