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. getting colors in bitmaps...

getting colors in bitmaps...

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsquestion
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.
  • T Offline
    T Offline
    the_augy
    wrote on last edited by
    #1

    I'm trying to use CBitmap to manipulate a bitmap, but there's no easy way for me to extract a color from a bitmap (like GetPixel(x, y) in CWnd-derived classes). Is there something I'm missing? Suggestions are well appreciated. Alternatively, is there a way to fill a bitmap with one color like FillRect() does with DCs? thanks, augy

    A C 2 Replies Last reply
    0
    • T the_augy

      I'm trying to use CBitmap to manipulate a bitmap, but there's no easy way for me to extract a color from a bitmap (like GetPixel(x, y) in CWnd-derived classes). Is there something I'm missing? Suggestions are well appreciated. Alternatively, is there a way to fill a bitmap with one color like FillRect() does with DCs? thanks, augy

      A Offline
      A Offline
      Azghar Hussain
      wrote on last edited by
      #2

      Hey, Try this. CDC *pDC = this->GetDC(); CDC mDC; mDC.CreateCompatibleDC(pDC); mDC.LoadBitmap(IDB_BITMAP1); Now you can used GetPixel() to extract color of bitmap. mDC.GetPixel(...); this->ReleaseDC(pDC); Hope this will work. If you have faith in the cause and the means and in God, the hot Sun will be cool for you.

      1 Reply Last reply
      0
      • T the_augy

        I'm trying to use CBitmap to manipulate a bitmap, but there's no easy way for me to extract a color from a bitmap (like GetPixel(x, y) in CWnd-derived classes). Is there something I'm missing? Suggestions are well appreciated. Alternatively, is there a way to fill a bitmap with one color like FillRect() does with DCs? thanks, augy

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        To work with a bitmap, you need to select it into a DC. The other way is to use a DIBSEction, then you can access the bits directly. Get/SetPixel are incredibly slow. Christian I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer

        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