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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to store a RGB bitmap image in to an 2d byte array and how to display that image from array

how to store a RGB bitmap image in to an 2d byte array and how to display that image from array

Scheduled Pinned Locked Moved C / C++ / MFC
c++graphicssysadmindata-structureshelp
2 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.
  • S Offline
    S Offline
    sravu25
    wrote on last edited by
    #1

    hi, i am doing vc++ course, i want to store the image in to an byte array that comes from web cam, after storing that data i want to display in to the server from byte stream. can any one help thanks

    enhzflepE 1 Reply Last reply
    0
    • S sravu25

      hi, i am doing vc++ course, i want to store the image in to an byte array that comes from web cam, after storing that data i want to display in to the server from byte stream. can any one help thanks

      enhzflepE Offline
      enhzflepE Offline
      enhzflep
      wrote on last edited by
      #2

      Sure, You get a byte stream from a webCam, & you'd like to display said image. Correct? Well, I'll assume that your data is pointed to by *rawData and that the lines aren't padded (each horizontal line of the image consumes width*3 bytes) wouldn't you just start-out by writing a few functions that will allow you to get all of the pixels one-by-one and insert them into a HBITMAP object? As a start, how about something to get pixel values (watch for endianess)

      COLORREF getPixelFromRawData(int x, int y)
      {
      char *data, r, g, b;
      long index;

      data = rawData;
      
      index = (y\*widthPixels\*3) + (x\*3)
      
      r = data\[index+0\];
      g = data\[index+1\];
      b = data\[index+2\];
      return RGB(r,g,b)
      

      }

      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