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. Efficient way of converting an 8bit array of grayscale pixel data into 24bpp bitmap for GDI+?

Efficient way of converting an 8bit array of grayscale pixel data into 24bpp bitmap for GDI+?

Scheduled Pinned Locked Moved C / C++ / MFC
graphicswinformsdata-structuresquestion
3 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.
  • K Offline
    K Offline
    Kiran Satish
    wrote on last edited by
    #1

    Hello, I have access to array of pixel data (size:512x512x8bpp) from a framegrabber which I currently assign to a 8bpp bitmap which is assigned to a GDI+ graphics object later on. Now, I would like to convert my array of 8bpp pixel data into 24bpp (BGRA, but I have no use for Alpha channel) and assign it to my bitmap and then modify individual pixel data to different colors depending on other conditions. When I say efficient, I want it to be done in real-time without much delay. Any suggestions? thanks

    PKNT

    CPalliniC J 2 Replies Last reply
    0
    • K Kiran Satish

      Hello, I have access to array of pixel data (size:512x512x8bpp) from a framegrabber which I currently assign to a 8bpp bitmap which is assigned to a GDI+ graphics object later on. Now, I would like to convert my array of 8bpp pixel data into 24bpp (BGRA, but I have no use for Alpha channel) and assign it to my bitmap and then modify individual pixel data to different colors depending on other conditions. When I say efficient, I want it to be done in real-time without much delay. Any suggestions? thanks

      PKNT

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

      Did you try the straightforward way (that is filling the ARGB memory area in a loop) and measured its performance?

      In testa che avete, signor di Ceprano?

      1 Reply Last reply
      0
      • K Kiran Satish

        Hello, I have access to array of pixel data (size:512x512x8bpp) from a framegrabber which I currently assign to a 8bpp bitmap which is assigned to a GDI+ graphics object later on. Now, I would like to convert my array of 8bpp pixel data into 24bpp (BGRA, but I have no use for Alpha channel) and assign it to my bitmap and then modify individual pixel data to different colors depending on other conditions. When I say efficient, I want it to be done in real-time without much delay. Any suggestions? thanks

        PKNT

        J Offline
        J Offline
        Jochen Arndt
        wrote on last edited by
        #3

        When the input data are 8 bit gray scale values just assign them to the R, G, and B values and set the aplha value to zero:

        // Assuming RGBA is an uint32_t / DWORD type and
        // *in an unsigned char / uint8_t pointer.
        RGBA *out = new RGBA[512 * 512];
        for (unsigned i = 0; i < 512 * 512; i++)
        {
        out[i] = (in[i] << 16) + (in[i] << 8) + in[i];
        }

        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