Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Image properties

Image properties

Scheduled Pinned Locked Moved C#
graphics
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    valiovalio
    wrote on last edited by
    #1

    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; }

    G 1 Reply Last reply
    0
    • V valiovalio

      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; }

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      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; }

      V 1 Reply Last reply
      0
      • G Guffa

        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; }

        V Offline
        V Offline
        valiovalio
        wrote on last edited by
        #3

        Thanks, You very helped me.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups