// Vereinbaren der logischen Palette HPALETTE CBildObjekt :: CreateDIBPalette (void) { HPALETTE hPal = NULL; if (!m_hDIB) return NULL; hPal = CreateBIPalette ((BITMAPINFOHEADER *)GlobalLock (m_hDIB)); GlobalUnlock (m_hDIB); return hPal; }
void C256bmp::OnPaint() { CPaintDC dc(this); /* device context for painting */ BITMAPINFO *pb=GetBitmap(); if (pb) { BITMAPINFOHEADER *pbh=( BITMAPINFOHEADER*)pb; HPALETTE hpal=CreateBIPalette (pbh); LPSTR pbits = (LPSTR)pbh + (WORD)pbh->biSize + PaletteSize(pbh); HPALETTE holdpal=::SelectPalette(dc.m_hDC,hpal,FALSE); if (!hSystemPalette) hSystemPalette=holdpal; ::RealizePalette(dc.m_hDC); ::SetDIBitsToDevice(dc.m_hDC,0,0,pbh->biWidth,pbh->biHeight,0,0,0,pbh->biHeight,pbits,pb,DIB_RGB_COLORS); ::SelectPalette(dc.m_hDC,holdpal,FALSE); ::DeleteObject(hpal); } ValidateRect(0); }