1

I am trying to get image from FileDialog My code :

private void BtnAddImage_Click(object sender, EventArgs e)
        {
            OpenFileDialog addImage = new OpenFileDialog();

            if (addImage.ShowDialog() == DialogResult.OK)
            {
                PbAddImage.Image = new Bitmap(addImage.FileName);
            }
            PbAddImage.Image.Save("C:\\Users\\musa\\Documents\\Hobby\\testUser.jpg");
        }

When i select images which height is bigger than width. (For example, width 1200 px , height 1600 px). In pictureBox i saw this image left rotated.But if image width is bigger than height , there is no problem.

And then i saved this image to file, in saved image there is no problem. It does not save as rotated.

How can i handle this issue ? Why images shows rotated ?

Edit : Here is my PbAddImage properties :

this.PbAddImage.Location = new System.Drawing.Point(157, 211);
this.PbAddImage.Name = "PbAddImage";
this.PbAddImage.Size = new System.Drawing.Size(112, 161);
this.PbAddImage.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.PbAddImage.TabIndex = 138;
this.PbAddImage.TabStop = false;
goGud
  • 4,163
  • 11
  • 39
  • 63
  • 1
    The problem has to lie in your `PbAddImage` control, that we know nothing about. Probably some auto-rotate property. – Tarec Feb 13 '14 at 14:26
  • What type of control is `PbAddImage`? The built-in [PictureBox](http://msdn.microsoft.com/en-us/library/system.windows.forms.picturebox%28v=vs.110%29.aspx) doesn't support rotation, so I think we need more information. – TypeIA Feb 13 '14 at 14:29
  • Is PbAddImage just a regular PictureBox? If so then there's nothing in there that would cause the image to be rotated. I think that it's probably actually the way you're viewing the image file in the first place that is rotating it. – jmcilhinney Feb 13 '14 at 14:29
  • I editted my question with PbAddImage properties – goGud Feb 13 '14 at 14:32
  • We don't need the properties as much as we need **its type**, because it appears to be a custom control or something; built-in PictureBox shouldn't do this. – TypeIA Feb 13 '14 at 14:59

1 Answers1

1

I've recreated everything you've put here and can't reproduce the issue, I'd say you must have some code somewhere rotating your PictureBox. I would suggest doing a Find All References on your PbAddImage to see if any code is rotating it that you're unaware of.

Sorry, I would have left a comment instead but don't have enough rep.

Chartreugz
  • 293
  • 1
  • 10
  • Thank you very much your comments gives me idea and i understand problem. It is not about my code. It is just about pictures which i take from file. I captured image from Iphone, that's the problem in some images when i recopy image from another folder and after i add them there is no problem. – goGud Feb 13 '14 at 15:15