2 Replies - 9743 Views - Last Post: 09 April 2009 - 05:19 PM Rate Topic: -----

#1 chronoTrigger  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 60
  • Joined: 08-October 07

Create new Bitmap, but receive Invalid Parameter?

Posted 09 April 2009 - 05:01 PM

Hello,

I'm trying to get picture resolution with the code below:

namespace GetImage
{
	public partial class Form1 : Form
	{
		public Form1()
		{
			InitializeComponent();
		}



		private void button1_Click(object sender, EventArgs e)
		{
			if (File.Exists(@"C:\MyImage.JPG"))
			{
				Image image = new Bitmap(@"C:\MyImage.JPG");

				int width = Convert.ToInt32(image.PhysicalDimension.Width);
				int height = Convert.ToInt32(image.PhysicalDimension.Height);
			}
		}
	}
}



but it throws exception saying that parameter is not valid and it'spointing to this statement
Image image = new Bitmap(@"C:\MyImage.JPG");


I put the image inside C:\, so the path and file name should be correct.

Does anybody know why?

thanks

This post has been edited by chronoTrigger: 09 April 2009 - 05:05 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Create new Bitmap, but receive Invalid Parameter?

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1638
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Create new Bitmap, but receive Invalid Parameter?

Posted 09 April 2009 - 05:18 PM

Do you get the error when you build or when you run it and press the button? I took your code and put it into a class and it compiles fine
Was This Post Helpful? 0
  • +
  • -

#3 chronoTrigger  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 60
  • Joined: 08-October 07

Re: Create new Bitmap, but receive Invalid Parameter?

Posted 09 April 2009 - 05:19 PM

Fortunately someone in msdn forum asked the same question and the replied is exactly solved my issue.

Although my image file exists and the size is not 0, but when I double click on the image itself, it doesn't show the picture, but just plain X-mark on the image that cant be viewed.

-----------------

Just to answer to PsychoCoder:
yes my program does compiled without error.

This post has been edited by chronoTrigger: 09 April 2009 - 05:21 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1