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 / C++ / MFC
  4. Convert image to byte array

Convert image to byte array

Scheduled Pinned Locked Moved C / C++ / MFC
data-structureshelpquestion
7 Posts 5 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.
  • H Offline
    H Offline
    hari_honey
    wrote on last edited by
    #1

    Hi, I need some help to convert an image to byte array and byte array to image. Can any one help? :)

    J M CPalliniC 3 Replies Last reply
    0
    • H hari_honey

      Hi, I need some help to convert an image to byte array and byte array to image. Can any one help? :)

      J Offline
      J Offline
      Jose David Pujo
      wrote on last edited by
      #2

      You can start with GetDIBits GDI API function. GetDIBits The GetDIBits function retrieves the bits of the specified compatible bitmap and copies them into a buffer as a DIB using the specified format. int GetDIBits( HDC hdc, // handle to DC HBITMAP hbmp, // handle to bitmap UINT uStartScan, // first scan line to set UINT cScanLines, // number of scan lines to copy LPVOID lpvBits, // array for bitmap bits LPBITMAPINFO lpbi, // bitmap data buffer UINT uUsage // RGB or palette index );

      G 1 Reply Last reply
      0
      • H hari_honey

        Hi, I need some help to convert an image to byte array and byte array to image. Can any one help? :)

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #3

        Jose's reply is great for HBITMAPs. Just using the word "image" is extremely vague. It's a lot easier for us to help you if you're a bit more specific. What kind of image? What format is the image? etc... Mark

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        H 1 Reply Last reply
        0
        • H hari_honey

          Hi, I need some help to convert an image to byte array and byte array to image. Can any one help? :)

          CPalliniC Offline
          CPalliniC Offline
          CPallini
          wrote on last edited by
          #4

          You don't need to: images are just a byte arrays. :rolleyes:

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          In testa che avete, signor di Ceprano?

          1 Reply Last reply
          0
          • M Mark Salsbery

            Jose's reply is great for HBITMAPs. Just using the word "image" is extremely vague. It's a lot easier for us to help you if you're a bit more specific. What kind of image? What format is the image? etc... Mark

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            H Offline
            H Offline
            hari_honey
            wrote on last edited by
            #5

            Actually i am writing code to diaply image read by an imagescanner device. In this i need to support all formats of images. So, i need to display an image which is in byte array format. How to do that?

            M 1 Reply Last reply
            0
            • H hari_honey

              Actually i am writing code to diaply image read by an imagescanner device. In this i need to support all formats of images. So, i need to display an image which is in byte array format. How to do that?

              M Offline
              M Offline
              Mark Salsbery
              wrote on last edited by
              #6

              hari_honey wrote:

              i need to support all formats of images

              All? That's pretty ambitious. Many image formats are published. You'll need to study the format specifications and read/write the byte streams accordingly. For BMP, GIF, JPEG, Exif, PNG, and TIFF, GDI+[^] can help. Mark

              Mark Salsbery Microsoft MVP - Visual C++ :java:

              1 Reply Last reply
              0
              • J Jose David Pujo

                You can start with GetDIBits GDI API function. GetDIBits The GetDIBits function retrieves the bits of the specified compatible bitmap and copies them into a buffer as a DIB using the specified format. int GetDIBits( HDC hdc, // handle to DC HBITMAP hbmp, // handle to bitmap UINT uStartScan, // first scan line to set UINT cScanLines, // number of scan lines to copy LPVOID lpvBits, // array for bitmap bits LPBITMAPINFO lpbi, // bitmap data buffer UINT uUsage // RGB or palette index );

                G Offline
                G Offline
                Gokulnath007
                wrote on last edited by
                #7

                How to get the blob data from this function? where is the blob data found in it??

                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