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. Why does my SetDIBColorTable fail ?

Why does my SetDIBColorTable fail ?

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 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.
  • N Offline
    N Offline
    ninck
    wrote on last edited by
    #1

    The return value for my SetDIBColorTable() function call is 0 (zero), so the function failed . Why ? Here's the source code : HBITMAP hOldBitmap = (HBITMAP)SelectObject(hMemDC, m_handlerToBMP); RGBQUAD pColors[256]; //RGBQUAD *oldpColors; for(int i=0; i<256; ++i) { pColors[i].rgbRed = i; pColors[i].rgbBlue = i; pColors[i].rgbGreen = i; pColors[i].rgbReserved = 0; } //pColors1=pColors; //GetDIBColorTable(hMemDC, 0, 256, oldpColors); UINT aaa=SetDIBColorTable(hMemDC,0,255,pColors);

    B 1 Reply Last reply
    0
    • N ninck

      The return value for my SetDIBColorTable() function call is 0 (zero), so the function failed . Why ? Here's the source code : HBITMAP hOldBitmap = (HBITMAP)SelectObject(hMemDC, m_handlerToBMP); RGBQUAD pColors[256]; //RGBQUAD *oldpColors; for(int i=0; i<256; ++i) { pColors[i].rgbRed = i; pColors[i].rgbBlue = i; pColors[i].rgbGreen = i; pColors[i].rgbReserved = 0; } //pColors1=pColors; //GetDIBColorTable(hMemDC, 0, 256, oldpColors); UINT aaa=SetDIBColorTable(hMemDC,0,255,pColors);

      B Offline
      B Offline
      bmzhao
      wrote on last edited by
      #2

      The hMemDC must 24 bit color DC, you need a 256 color DC.

      N 1 Reply Last reply
      0
      • B bmzhao

        The hMemDC must 24 bit color DC, you need a 256 color DC.

        N Offline
        N Offline
        ninck
        wrote on last edited by
        #3

        So how do I create a 256 color DC ?

        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