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