char szFileName[MAX_PATH];
strcpy(szFileName,"res\\24.bmp");
HANDLE hFile = CreateFile(szFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
if(hFile == INVALID_HANDLE_VALUE)
{
AfxMessageBox("error");
}
DWORD dwSize = GetFileSize(hFile, NULL);
BYTE* buf = new BYTE[dwSize];
DWORD dwByet;
bool b = ReadFile(hFile, buf, dwSize, &dwByet,NULL);
BITMAPFILEHEADER bitHead;
bitHead.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);;
bitHead.bfReserved2 = 0;
bitHead.bfReserved1 = 0;
bitHead.bfSize = sizeof(bitHead) + sizeof(BITMAPINFO);
bitHead.bfType = 0x4d42;
BITMAPINFO bmpInfo;
bmpInfo.bmiHeader.biSize = sizeof(bmpInfo);
bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER) ;
bmpInfo.bmiHeader.biWidth = 500;
bmpInfo.bmiHeader.biHeight = 500;
bmpInfo.bmiHeader.biPlanes = 2; //key;
bmpInfo.bmiHeader.biBitCount = 24;
bmpInfo.bmiHeader.biCompression = BI_RGB ;
bmpInfo.bmiHeader.biSizeImage = 500*500;
bmpInfo.bmiHeader.biXPelsPerMeter = 0 ;
bmpInfo.bmiHeader.biYPelsPerMeter = 0 ;
bmpInfo.bmiHeader.biClrUsed = 0 ;
bmpInfo.bmiHeader.biClrImportant = 0 ;
FILE *fp;
fp = fopen("abc.txt","w+");
if(fp == NULL)
{
AfxMessageBox("error");
}
DWORD dwRet = -1;
dwRet = fwrite(&bitHead, 1,sizeof(bitHead), fp);
dwRet = fwrite(&bmpInfo, 1,sizeof(bmpInfo), fp);
dwRet = fwrite(buf,1,dwSize, fp);