//************************************************************************ CDib::CDib(PDIB pdib, LPTR lp, BOOL fCopyBits) //************************************************************************ { m_bmiHeader = *pdib->GetInfoHeader(); hmemcpy( m_rgbQuad, pdib->GetColors(), sizeof(m_rgbQuad)); m_lp = lp; if (fCopyBits) hmemcpy(m_lp, pdib->GetPtr(), pdib->GetSizeImage()); m_iRefCount = 0; AddRef(); }
//************************************************************************ BOOL CDib::Create( PDIB pdib ) //************************************************************************ { DWORD dwSizeImage; dwSizeImage = pdib->GetSizeImage(); if ( !(m_lp = AllocX( dwSizeImage + 1024, GMEM_ZEROINIT )) ) { return FALSE; } m_bmiHeader = *pdib->GetInfoHeader(); hmemcpy( m_rgbQuad, pdib->GetColors(), sizeof(m_rgbQuad)); hmemcpy(m_lp, pdib->GetPtr(), pdib->GetSizeImage()); return TRUE; }
BOOL CAliasApp::AntiAliasDib(PDIB pForeDib, PDIB pCompDib) { #ifndef CPO if (pForeDib->GetHeight() != pCompDib->GetHeight() || pForeDib->GetWidth() != pCompDib->GetWidth()) { MessageBox(NULL, "Bitmaps are different sizes", "Error", MB_ICONSTOP|MB_OK); return(FALSE); } if (pForeDib->GetBitCount() != 24 || pCompDib->GetBitCount() != 24) { MessageBox(NULL, "Bitmaps must both be 24-bits", "Error", MB_ICONSTOP|MB_OK); return(FALSE); } RGBS rgb; BOOL fColor; LPTR lpFore = pForeDib->GetPtr(); if (FALSE) rgb.red = rgb.green = rgb.blue = 148; else rgb = *((LPRGB)pForeDib->GetXY(0, 0)); BYTE r = rgb.red; BYTE g = rgb.green; BYTE b = rgb.blue; fColor = ((r == 255 && g == 0 && b == 0) || // red (r == 0 && g == 255 && b == 0) || // green (r == 0 && g == 0 && b == 255) || // blue (r == 0 && g == 255 && b == 255) || // cyan (r == 255 && g == 0 && b == 255) || // magenta (r == 255 && g == 255 && b == 0)); // yellow if (!fColor) { m_rgbTrans.red = 255; m_rgbTrans.green = 0; m_rgbTrans.blue = 255; } else { m_rgbTrans = rgb; } #endif LPTR lpComp = pCompDib->GetPtr(); UINT uWidthBytes = pCompDib->GetWidthBytes(); int iHeight = abs(pCompDib->GetHeight()); while (--iHeight >= 0) { int iWidth = pCompDib->GetWidth(); LPRGB lpC = (LPRGB)lpComp; m_Quantize.CountFrequencies((LPRGBTRIPLE)lpComp, iWidth); #ifndef CPO LPRGB lpF = (LPRGB)lpFore; while (--iWidth >= 0) { if (lpF->red != r || lpF->green != g || lpF->blue != b) { *lpF++ = *lpC++; } else { if (!fColor) { lpF->red = 255; lpF->green = 0; lpF->blue = 255; } ++lpF; ++lpC; } } lpFore += uWidthBytes; #endif lpComp += uWidthBytes; } return(TRUE); }