Click here to Skip to main content
15,903,203 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to extract the bitmap (HBITMAP) from a BITMAPINFOHEADER variable? Pin
Chris Losinger31-Mar-10 7:31
professionalChris Losinger31-Mar-10 7:31 
GeneralRe: How to extract the bitmap (HBITMAP) from a BITMAPINFOHEADER variable? Pin
bioan31-Mar-10 7:58
professionalbioan31-Mar-10 7:58 
GeneralRe: How to extract the bitmap (HBITMAP) from a BITMAPINFOHEADER variable? Pin
Chris Losinger31-Mar-10 8:06
professionalChris Losinger31-Mar-10 8:06 
GeneralRe: How to extract the bitmap (HBITMAP) from a BITMAPINFOHEADER variable? Pin
bioan31-Mar-10 8:23
professionalbioan31-Mar-10 8:23 
GeneralRe: How to extract the bitmap (HBITMAP) from a BITMAPINFOHEADER variable? Pin
Chris Losinger31-Mar-10 8:30
professionalChris Losinger31-Mar-10 8:30 
GeneralRe: How to extract the bitmap (HBITMAP) from a BITMAPINFOHEADER variable? Pin
bioan31-Mar-10 8:39
professionalbioan31-Mar-10 8:39 
GeneralRe: How to extract the bitmap (HBITMAP) from a BITMAPINFOHEADER variable? Pin
Chris Losinger31-Mar-10 9:08
professionalChris Losinger31-Mar-10 9:08 
GeneralRe: How to extract the bitmap (HBITMAP) from a BITMAPINFOHEADER variable? Pin
bioan31-Mar-10 9:38
professionalbioan31-Mar-10 9:38 
I have used your code as below:

BITMAPINFOHEADER *pHeader;
pHeader = (BITMAPINFOHEADER *)(odImage.bmp.begin() );
if(!pHeader)
return TRUE;
HBITMAP hbm;
// how many colors in this DIB?
int nColors = pHeader->biClrUsed ? pHeader->biClrUsed : 1 << pHeader->biBitCount;

BITMAPINFO &bmInfo = *(LPBITMAPINFO)pHeader ;// make cast from BITMAPINFOHEADER!
LPVOID lpDIBBits;
if( bmInfo.bmiHeader.biBitCount > 8 )
{
lpDIBBits = (LPVOID)((UINT32 *)(bmInfo.bmiColors +
bmInfo.bmiHeader.biClrUsed) + ((bmInfo.bmiHeader.biCompression == BI_BITFIELDS) ? 3 : 0));
}
else
{
lpDIBBits = (LPVOID)(bmInfo.bmiColors + nColors);
}

void *ppvBits = NULL;
hbm = CreateDIBSection(NULL,
(LPBITMAPINFO)pHeader,
DIB_RGB_COLORS,
&ppvBits,
NULL,
0);

m_TestBitButtonCtrl.SetBitmap(hbm);


I'm still got a black bitmap, HBITMAP is not NULL (checked with debug!).
Strange!
What I'm wrong?

Ioan
GeneralRe: How to extract the bitmap (HBITMAP) from a BITMAPINFOHEADER variable? Pin
Chris Losinger31-Mar-10 9:46
professionalChris Losinger31-Mar-10 9:46 
GeneralRe: How to extract the bitmap (HBITMAP) from a BITMAPINFOHEADER variable? Pin
bioan31-Mar-10 9:58
professionalbioan31-Mar-10 9:58 
GeneralRe: How to extract the bitmap (HBITMAP) from a BITMAPINFOHEADER variable? Pin
Chris Losinger31-Mar-10 10:07
professionalChris Losinger31-Mar-10 10:07 
GeneralRe: How to extract the bitmap (HBITMAP) from a BITMAPINFOHEADER variable? Pin
bioan31-Mar-10 10:22
professionalbioan31-Mar-10 10:22 
GeneralRe: How to extract the bitmap (HBITMAP) from a BITMAPINFOHEADER variable? Pin
Chris Losinger31-Mar-10 10:30
professionalChris Losinger31-Mar-10 10:30 
GeneralRe: How to extract the bitmap (HBITMAP) from a BITMAPINFOHEADER variable? Pin
bioan31-Mar-10 10:37
professionalbioan31-Mar-10 10:37 
GeneralRe: How to extract the bitmap (HBITMAP) from a BITMAPINFOHEADER variable? Pin
bioan31-Mar-10 10:59
professionalbioan31-Mar-10 10:59 
GeneralRe: How to extract the bitmap (HBITMAP) from a BITMAPINFOHEADER variable? Pin
Chris Losinger31-Mar-10 16:42
professionalChris Losinger31-Mar-10 16:42 
GeneralRe: How to extract the bitmap (HBITMAP) from a BITMAPINFOHEADER variable? Pin
bioan1-Apr-10 22:50
professionalbioan1-Apr-10 22:50 
GeneralRe: How to extract the bitmap (HBITMAP) from a BITMAPINFOHEADER variable? Pin
Chris Losinger2-Apr-10 1:15
professionalChris Losinger2-Apr-10 1:15 
QuestionGetRegValue and using it correctly, need help. Pin
rbwest8631-Mar-10 7:08
rbwest8631-Mar-10 7:08 
AnswerRe: GetRegValue and using it correctly, need help. Pin
Richard MacCutchan31-Mar-10 7:31
mveRichard MacCutchan31-Mar-10 7:31 
QuestionAlways on top Pin
trioum31-Mar-10 7:01
trioum31-Mar-10 7:01 
AnswerRe: Always on top Pin
Graham Breach31-Mar-10 7:28
Graham Breach31-Mar-10 7:28 
AnswerRe: Always on top Pin
Richard MacCutchan31-Mar-10 7:33
mveRichard MacCutchan31-Mar-10 7:33 
QuestionCListCtrl won't update as expected Pin
Vaclav_31-Mar-10 5:56
Vaclav_31-Mar-10 5:56 
AnswerRe: CListCtrl won't update as expected Pin
Code-o-mat31-Mar-10 6:14
Code-o-mat31-Mar-10 6:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.