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. 24 bit bitmap doubt ..

24 bit bitmap doubt ..

Scheduled Pinned Locked Moved C#
graphicsdata-structuresquestion
4 Posts 3 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.
  • S Offline
    S Offline
    Software_Specialist
    wrote on last edited by
    #1

    Hi i am trying to check whether the bitmap file is 24 bit or not. For this i have written a below code FileStream File byte[] buffer = new byte[2]; File.Seek(28,0); File.Read(buffer,0,2); Int16 nBit = BitConverter.ToInt16(buffer, 0); The above code works fine and give me the value of nBit as 24. But i don't understand the exact working of it. Ok first it creates 2byte array, then i have a doubt over 2nd line i.e. File.Read(28,0); Why current position is set to 28 here....?? It gives correct value when i set that to 28 and by next line the position jumps 2 place further i.e. 30 and by then i get correct value 24. Can any one please explain me this behaviour...? Thanks

    M I 2 Replies Last reply
    0
    • S Software_Specialist

      Hi i am trying to check whether the bitmap file is 24 bit or not. For this i have written a below code FileStream File byte[] buffer = new byte[2]; File.Seek(28,0); File.Read(buffer,0,2); Int16 nBit = BitConverter.ToInt16(buffer, 0); The above code works fine and give me the value of nBit as 24. But i don't understand the exact working of it. Ok first it creates 2byte array, then i have a doubt over 2nd line i.e. File.Read(28,0); Why current position is set to 28 here....?? It gives correct value when i set that to 28 and by next line the position jumps 2 place further i.e. 30 and by then i get correct value 24. Can any one please explain me this behaviour...? Thanks

      M Offline
      M Offline
      Mike Dimmick
      wrote on last edited by
      #2

      See The .bmp file format[^]. Note that this lists the fields starting from byte position 1, while the .NET Framework starts counting at 0.

      Stability. What an interesting concept. -- Chris Maunder

      1 Reply Last reply
      0
      • S Software_Specialist

        Hi i am trying to check whether the bitmap file is 24 bit or not. For this i have written a below code FileStream File byte[] buffer = new byte[2]; File.Seek(28,0); File.Read(buffer,0,2); Int16 nBit = BitConverter.ToInt16(buffer, 0); The above code works fine and give me the value of nBit as 24. But i don't understand the exact working of it. Ok first it creates 2byte array, then i have a doubt over 2nd line i.e. File.Read(28,0); Why current position is set to 28 here....?? It gives correct value when i set that to 28 and by next line the position jumps 2 place further i.e. 30 and by then i get correct value 24. Can any one please explain me this behaviour...? Thanks

        I Offline
        I Offline
        Ilya Verbitskiy
        wrote on last edited by
        #3

        Hi, 28 is an offset in bitmap file which store information about number of bits per pixel. For additional information about bitmaps format you can see Bitmap Image article.

        S 1 Reply Last reply
        0
        • I Ilya Verbitskiy

          Hi, 28 is an offset in bitmap file which store information about number of bits per pixel. For additional information about bitmaps format you can see Bitmap Image article.

          S Offline
          S Offline
          Software_Specialist
          wrote on last edited by
          #4

          okay thanks... So 54 is the header size in bitmap file...

          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