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. Graphics
  4. BITMAPINFO + Colour video

BITMAPINFO + Colour video

Scheduled Pinned Locked Moved Graphics
helpcombusinesstoolsquestion
8 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.
  • J Offline
    J Offline
    jossion
    wrote on last edited by
    #1

    Hi all, This is with reference to an old message posted by me which you can find here http://www.codeproject.com/script/Forums/View.aspx?fid=387159&msg=2452196[^] For the past one year this piece of code which Mr.Mark gave me; satisfied my requirements excellently. Now I have come up with a problem of displaying colour video. I will need help once again in modifying the code to colour mode. The main problem is how I should arrange the pixels and where to write it. What are the BITMAPINFO parameters that I have to change. Hope to get a reply at the earliest.

    M 1 Reply Last reply
    0
    • J jossion

      Hi all, This is with reference to an old message posted by me which you can find here http://www.codeproject.com/script/Forums/View.aspx?fid=387159&msg=2452196[^] For the past one year this piece of code which Mr.Mark gave me; satisfied my requirements excellently. Now I have come up with a problem of displaying colour video. I will need help once again in modifying the code to colour mode. The main problem is how I should arrange the pixels and where to write it. What are the BITMAPINFO parameters that I have to change. Hope to get a reply at the earliest.

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

      How many bits per pixel (what's the pixel format)? Mark

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

      J 1 Reply Last reply
      0
      • M Mark Salsbery

        How many bits per pixel (what's the pixel format)? Mark

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

        J Offline
        J Offline
        jossion
        wrote on last edited by
        #3

        8 bit per pixel in RGB format.I have three arrays of unsigned char for each R,G and B values.

        M 1 Reply Last reply
        0
        • J jossion

          8 bit per pixel in RGB format.I have three arrays of unsigned char for each R,G and B values.

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

          So do you mean 24 bits per pixel? There's no 8bpp RGB format for Windows bitmaps... Mark

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

          J 1 Reply Last reply
          0
          • M Mark Salsbery

            So do you mean 24 bits per pixel? There's no 8bpp RGB format for Windows bitmaps... Mark

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

            J Offline
            J Offline
            jossion
            wrote on last edited by
            #5

            Exactly 24bpp. But what I meant is I have 8 bits of R,8 bits of G and 8 bits of B seperately in seperate arrays. Now with respect to the routine what you have given me last time http://www.codeproject.com/script/Forums/View.aspx?fid=387159&msg=2452196[^] what are the modifications I have to do

            M 1 Reply Last reply
            0
            • J jossion

              Exactly 24bpp. But what I meant is I have 8 bits of R,8 bits of G and 8 bits of B seperately in seperate arrays. Now with respect to the routine what you have given me last time http://www.codeproject.com/script/Forums/View.aspx?fid=387159&msg=2452196[^] what are the modifications I have to do

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

              To create the DIBSection, you can drop the palette and change the bmiHeader.biBitCount:

              BITMAPINFO \*bm = (BITMAPINFO \*)new BYTE\[sizeof(BITMAPINFO)\];
              
              bm->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
              bm->bmiHeader.biWidth = 176;
              bm->bmiHeader.biHeight = 144;
              bm->bmiHeader.biPlanes = 1;
              bm->bmiHeader.biBitCount = 24;
              bm->bmiHeader.biCompression = BI\_RGB;
              bm->bmiHeader.biSizeImage = 0;
              bm->bmiHeader.biXPelsPerMeter = 0;
              bm->bmiHeader.biYPelsPerMeter = 0;
              bm->bmiHeader.biClrUsed = 0;
              bm->bmiHeader.biClrImportant = 0;
              
              BYTE \*pBitmapBits;
              HBITMAP hBitmap = ::CreateDIBSection(NULL, bm, DIB\_RGB\_COLORS, (void\*\*)&pBitmapBits, NULL, 0);
              
              if (hBitmap)
              {
              
                  // do your rendering stuff here!
              
              
                  ::DeleteObject(hBitmap);
              }
              
              delete\[\] (BYTE \*)bm;
              

              jossion wrote:

              I have 8 bits of R,8 bits of G and 8 bits of B seperately in seperate arrays

              The pixel data (pointed to by pBitmapBits) will now be a RGBTRIPLE struct for each pixel:

              // From the docs:

              typedef struct tagRGBTRIPLE {
              BYTE rgbtBlue;
              BYTE rgbtGreen;
              BYTE rgbtRed;
              } RGBTRIPLE;

              You'll need to take the individual RGB component bytes from the arrays and pack them in the RGBTRIPLE format - BGRBGRBGR... Mark

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

              A 1 Reply Last reply
              0
              • M Mark Salsbery

                To create the DIBSection, you can drop the palette and change the bmiHeader.biBitCount:

                BITMAPINFO \*bm = (BITMAPINFO \*)new BYTE\[sizeof(BITMAPINFO)\];
                
                bm->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
                bm->bmiHeader.biWidth = 176;
                bm->bmiHeader.biHeight = 144;
                bm->bmiHeader.biPlanes = 1;
                bm->bmiHeader.biBitCount = 24;
                bm->bmiHeader.biCompression = BI\_RGB;
                bm->bmiHeader.biSizeImage = 0;
                bm->bmiHeader.biXPelsPerMeter = 0;
                bm->bmiHeader.biYPelsPerMeter = 0;
                bm->bmiHeader.biClrUsed = 0;
                bm->bmiHeader.biClrImportant = 0;
                
                BYTE \*pBitmapBits;
                HBITMAP hBitmap = ::CreateDIBSection(NULL, bm, DIB\_RGB\_COLORS, (void\*\*)&pBitmapBits, NULL, 0);
                
                if (hBitmap)
                {
                
                    // do your rendering stuff here!
                
                
                    ::DeleteObject(hBitmap);
                }
                
                delete\[\] (BYTE \*)bm;
                

                jossion wrote:

                I have 8 bits of R,8 bits of G and 8 bits of B seperately in seperate arrays

                The pixel data (pointed to by pBitmapBits) will now be a RGBTRIPLE struct for each pixel:

                // From the docs:

                typedef struct tagRGBTRIPLE {
                BYTE rgbtBlue;
                BYTE rgbtGreen;
                BYTE rgbtRed;
                } RGBTRIPLE;

                You'll need to take the individual RGB component bytes from the arrays and pack them in the RGBTRIPLE format - BGRBGRBGR... Mark

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

                A Offline
                A Offline
                akirilov
                wrote on last edited by
                #7

                I would suggest: bm->bmiHeader.biHeight = -144; instead of bm->bmiHeader.biHeight = 144; When height is positive, the bitmap is bottom-up oriented. In 99% our bitmap sources are up-bottom oriented.

                M 1 Reply Last reply
                0
                • A akirilov

                  I would suggest: bm->bmiHeader.biHeight = -144; instead of bm->bmiHeader.biHeight = 144; When height is positive, the bitmap is bottom-up oriented. In 99% our bitmap sources are up-bottom oriented.

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

                  That's fine....as long as the OP remembers to adjust his/her direct pixel access calculations accordingly :)

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

                  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