I’m trying to select an area of an image I’ve selected using openfiledialog
The area I’m trying to select is 16×16 from x,y coordinates 5,5
Once selected I want to draw the 16×16 image into another pictureBox at coordinates 0,0
This is the code I’ve got but I can’t get it to select the correct part of the original image, anybody any suggestions as to why it doesn’t work?
DialogResult result = openFileDialog1.ShowDialog();
if (result == DialogResult.OK) // Test result.
{
Image origImage = Image.FromFile(openFileDialog1.FileName);
pictureBoxSkin.Image = origImage;
lblOriginalFilename.Text = openFileDialog1.SafeFileName;
System.Drawing.Bitmap bmp = new Bitmap(16, 16);
Graphics g3 = Graphics.FromImage(bmp);
g3.DrawImageUnscaled(origImage, 0, 0, 16, 16);
Graphics g2 = pictureBoxNew.CreateGraphics();
g2.DrawImageUnscaled(bmp, 0, 0, 16, 16);
}
In order to select the correct section, just replace:
with