User draw something like signature, there just are some black point in DC, it's easy to write to a color BMP file, but how to write it to a white and black file
Code:
bool CStaticSign::SaveToFile(CString strFile) { FILE * pFile; _wfopen_s(&pFile, strFile, L"wb"); if(pFile == NULL) { return false; } BITMAPFILEHEADER bmfh; int nBitsOffset = sizeof(BITMAPFILEHEADER) + m_BMIH.biSize; LONG lImageSize = m_BMIH.biSizeImage; LONG lFileSize = nBitsOffset + lImageSize; bmfh.bfType = 'B'+('M'<<8); bmfh.bfOffBits = nBitsOffset; bmfh.bfSize = lFileSize; bmfh.bfReserved1 = bmfh.bfReserved2 = 0; //Write the bitmap file header size_t nWrittenFileHeaderSize = fwrite(&bmfh, 1, sizeof(BITMAPFILEHEADER), pFile); //And then the bitmap info header size_t nWrittenInfoHeaderSize = fwrite(&m_BMIH, 1, sizeof(BITMAPINFOHEADER), pFile); //Finally, write the image data itself -- the data represents our drawing size_t nWrittenDIBDataSize = fwrite(m_pDrawingSurfaceBits, 1, lImageSize, pFile); fclose(pFile);
return true; }
Visual C++5
|