Image properties
-
Hello, I`m scaned a picture and set the size height 10cm width 10cm, now when I load that picture, I can`t find these parameters, I can only find number of pixels, but nothing about size in centimetres. sring path; Bitmap image1; path= OpenFile(); image1 = new Bitmap(@path, true); } //--------------------------------------- private string OpenFile() { OpenFileDialog dlgOpenFile = new OpenFileDialog(); dlgOpenFile.ShowReadOnly = true; if (dlgOpenFile.ShowDialog() == DialogResult.OK) { string path = dlgOpenFile.FileName; return path; } return null; }
-
Hello, I`m scaned a picture and set the size height 10cm width 10cm, now when I load that picture, I can`t find these parameters, I can only find number of pixels, but nothing about size in centimetres. sring path; Bitmap image1; path= OpenFile(); image1 = new Bitmap(@path, true); } //--------------------------------------- private string OpenFile() { OpenFileDialog dlgOpenFile = new OpenFileDialog(); dlgOpenFile.ShowReadOnly = true; if (dlgOpenFile.ShowDialog() == DialogResult.OK) { string path = dlgOpenFile.FileName; return path; } return null; }
The size in centimeters is not stored in the file. What you are looking for is the resolution of the image, e.g. the PPI (or DPI) setting. PPI stands for Pixels Per Inch. Often the less accurate term DPI is used, which stands for Dots Per Inch. From the size in pixels and the resolution, you can calculate the size of the image in inches, then you convert that in centimeters. If you for an example get this information from the file:
int ppi = 600; int widthInPixels = 2362; int heightInPixels = 2362;
The you can calcluate the size:double widthInInches = (double)widthInPixels / (double)ppi; // will be approx 3.93667 double widthInCentimeters = widthInInches * 2.54; // will be approx 9.99913
...and the same way for height. --- b { font-weight: normal; } -
The size in centimeters is not stored in the file. What you are looking for is the resolution of the image, e.g. the PPI (or DPI) setting. PPI stands for Pixels Per Inch. Often the less accurate term DPI is used, which stands for Dots Per Inch. From the size in pixels and the resolution, you can calculate the size of the image in inches, then you convert that in centimeters. If you for an example get this information from the file:
int ppi = 600; int widthInPixels = 2362; int heightInPixels = 2362;
The you can calcluate the size:double widthInInches = (double)widthInPixels / (double)ppi; // will be approx 3.93667 double widthInCentimeters = widthInInches * 2.54; // will be approx 9.99913
...and the same way for height. --- b { font-weight: normal; }Thanks, You very helped me.