do you want to store this into database?if it is ,this code maybe fit you. // BEGIN setup the CLongBinary for the bitmap // NB. All lines are absolutely necessary BITMAP bm; m_bitmap.GetBitmap(&bm); m_pSet->m_binary.m_dwDataLength = sizeof(bm) + (bm.bmHeight * bm.bmWidthBytes); m_pSet->m_binary.m_hData = GlobalReAlloc( m_pSet->m_binary.m_hData, m_pSet->m_binary.m_dwDataLength, GMEM_MOVEABLE|GMEM_ZEROINIT ); ASSERT( m_pSet->m_binary.m_hData != NULL ); BYTE *pByte = (BYTE *)::GlobalLock(m_pSet->m_binary.m_hData); memcpy(pByte,&bm,sizeof(bm)); m_bitmap.GetBitmapBits( DWORD(bm.bmHeight*bm.bmWidthBytes), pByte+sizeof(bm) ); ::GlobalUnlock(m_pSet->m_binary.m_hData); m_pSet->SetFieldDirty(&m_pSet->m_binary,TRUE); m_pSet->SetFieldNull(&m_pSet->m_binary,FALSE); // END setup the CLongBinary
// BEGIN setup the CLongBinary for the bitmap
// NB. All lines are absolutely necessary
BITMAP bm;
m_bitmap.GetBitmap(&bm); m_pSet->m_binary.m_dwDataLength = sizeof(bm) + (bm.bmHeight *
bm.bmWidthBytes);
m_pSet->m_binary.m_hData = GlobalReAlloc( m_pSet->m_binary.m_hData,
m_pSet->m_binary.m_dwDataLength,
GMEM_MOVEABLE|GMEM_ZEROINIT
);
ASSERT( m_pSet->m_binary.m_hData != NULL ); BYTE *pByte = (BYTE *)::GlobalLock(m_pSet->m_binary.m_hData);
memcpy(pByte,&bm,sizeof(bm));
m_bitmap.GetBitmapBits( DWORD(bm.bmHeight*bm.bmWidthBytes),
pByte+sizeof(bm) );
::GlobalUnlock(m_pSet->m_binary.m_hData); m_pSet->SetFieldDirty(&m_pSet->m_binary,TRUE);
m_pSet->SetFieldNull(&m_pSet->m_binary,FALSE);
// END setup the CLongBinary