0
Answer

How to get dpi of image in .net

Ask a question
franches

franches

19y
4.2k
1
Hi, i really don't know if this is the right place to ask this question. i have this code void MenuOpenClick(object sender, System.EventArgs e) { if (openFileDialog.ShowDialog()==DialogResult.OK) { string directory = openFileDialog.FileName; textBox10.Text = Path.GetDirectoryName(directory); string filename = openFileDialog.FileName; textBox1.Text = Path.GetFileNameWithoutExtension(filename); textBox2.Clear(); textBox3.Clear(); textBox4.Clear(); textBox5.Clear(); textBox6.Clear(); textBox7.Clear(); textBox8.Clear(); textBox9.Clear(); buttonCreate.Enabled = false; Image image = Image.FromFile(openFileDialog.FileName); this.Text = String.Concat("Image Transformation (" + openFileDialog.FileName + ")"); int x = image.Size.Width; string xw = Convert.ToString(x); int y = image.Size.Height; string yh = Convert.ToString(y); textBox2.AppendText(xw); textBox3.AppendText(yh); pictureBox.Image=Image.FromFile(openFileDialog.FileName); .Show(p); adjustPictureBoxSize(); } }


my problem now is i don't know how to get the dpi of the image i opened. i would like to put it inside textbox10. hope someone could help me with the code. the type of images are tiff, jpeg, and bmp. thanks in advance.