Displaying image from list and saving it to disk
Hi I am trying to do the following two things.
1. To display a specific image from a list. Problem: I always get the first cropped part stored not the last as in the example.
2. To save the image into disk. Problem: No file is genrated on disk.
Please carefully examine the code:
//evertime the picture is cropped the mouseup event will run
public void ImageBox_MouseUp(object sender, MouseEventArgs e)if (this.drawingRectangle)this.areas.Add(this.rect);this.drawingRectangle = false;
{
Bitmap cropped = new Bitmap(rect.Width, rect.Height);Graphics g = Graphics.FromImage(cropped);g.DrawImage(bm, new Rectangle(0, 0, cropped.Width, cropped.Height), rect.X, rect.Y, cropped.Width, cropped.Height, GraphicsUnit.Pixel);this.CroppedImages.Add(bm);
pictureBox3.Image = CroppedImages.Last(); //This shows only the first cropped file, not the last one
pictureBox3.Image.Save("c:\\program files\\image.jpeg"); // This doesn't do anything no file is created
cropped.Dispose();
g.Dispose();
}
Thanks in advance