void CChap1_4View::OnDraw(CDC* pDC) { // CChap1_4Doc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if(pDoc->m_pDib==NULL) return;
// infoHead DIB е BITMAPINFOHEADER BITMAPINFOHEADER *infoHead=(BITMAPINFOHEADER*)pDoc->m_pDib;
// DIB λ int width=infoHead->biWidth; int height=infoHead->biHeight; int biBitCount=infoHead->biBitCount;
// 0 // pow(2,biBitCount) int colorTableLng; if(biBitCount!=24) colorTableLng=pow(2,biBitCount); else colorTableLng=0;
// 壬hPalette //hOldPal HPALETTE hPalette=0, hOldPal; if(colorTableLng!=0){
// pColorTable DIB RGBQUAD *pColorTable=(RGBQUAD *)(pDoc->m_pDib+ sizeof(BITMAPINFOHEADER));
// LOGPALETTE LPLOGPALETTE pLogPal = (LPLOGPALETTE)new char[2*sizeof(WORD) +colorTableLng * sizeof(PALETTEENTRY)]; pLogPal->palVersion = 0x300; pLogPal->palNumEntries =colorTableLng; for(int i = 0; i < colorTableLng; i++) { pLogPal->palPalEntry[i].peRed = pColorTable[i].rgbRed; pLogPal->palPalEntry[i].peGreen =pColorTable[i].rgbGreen; pLogPal->palPalEntry[i].peBlue = pColorTable[i].rgbBlue; pLogPal->palPalEntry[i].peFlags = 0; }
// hPalette = ::CreatePalette(pLogPal);
// hOldPal=::SelectPalette(pDC->GetSafeHdc(), hPalette, TRUE);
// pDC->RealizePalette();
// delete []pLogPal; }
//DIB pDC->SetStretchBltMode(COLORONCOLOR);
//pImgData DIB λ unsigned char* pImgData=(unsigned char*)(pDoc->m_pDib+ sizeof(BITMAPINFOHEADER)+sizeof(RGBQUAD) * colorTableLng);
// DIB ::StretchDIBits(pDC->GetSafeHdc(), 0, 0, width, height, 0, 0, width, height, pImgData, (LPBITMAPINFO)(pDoc->m_pDib), DIB_RGB_COLORS, SRCCOPY);
// if(hOldPal!=NULL) ::SelectPalette(pDC->GetSafeHdc(), hOldPal, TRUE); } |