正做一项目,很急,在网上看到了一个,但是没成功,大家指点一下吧最好有现成的代码~
void OnBtnCreateBMP()
         CBitmap Bitmap;
unsigned char* pData;
Bitmap.CreateBitmap(50,50,1,24,NULL);
BITMAP bm;
Bitmap.GetObject(sizeof(BITMAP),&bm);
pData=new unsigned char [bm.bmHeight * bm.bmWidthBytes];
for (int y = 0; y < bm.bmHeight; y ++)
{
for (int x = 0; x < bm.bmWidth; x ++)
{
pData[x * 3 + y * bm.bmWidthBytes] = 255;
pData[x * 3 + 1 + y * bm.bmWidthBytes ] = 0;
pData[x * 3 + 2 + y * bm.bmWidthBytes ] = 255;
}
}
Bitmap.SetBitmapBits(bm.bmHeight * bm.bmWidthBytes, pData);
  //static int filecount = 0;
  CString name;
  name = "..\\CreatBMP\\Debug\\SAMPLE.bmp";//m_Path+name;
  BITMAPFILEHEADER bfh;
  bfh.bfReserved1 = bfh.bfReserved2 = 0;
  bfh.bfType = ((WORD) ('M' << 8) | 'B');
  bfh.bfSize = 54 + bm.bmHeight * bm.bmWidthBytes;
  bfh.bfOffBits = 54;  BITMAPINFOHEADER bih;
  bih.biBitCount = 24;
  bih.biClrImportant = 0;
  bih.biClrUsed = 0;
  bih.biCompression = 0;
  bih.biHeight = bm.bmHeight;
  bih.biPlanes = 1;
  bih.biSize = sizeof(BITMAPINFOHEADER);
  bih.biSizeImage = bm.bmHeight * bm.bmWidthBytes;
  bih.biWidth = bm.bmWidth;
  bih.biXPelsPerMeter = 0;
  bih.biYPelsPerMeter = 0;
  CFile bf;
  if (bf.Open(name, CFile::modeCreate | CFile::modeWrite))
  {
   bf.WriteHuge(&bfh, sizeof(BITMAPFILEHEADER));
   bf.WriteHuge(&bih, sizeof(BITMAPINFOHEADER));
   bf.WriteHuge(pData, bm.bmHeight * bm.bmWidthBytes);
   bf.Close();  }在将pData赋值RGB之后,CFile去不能创建呢?请各位帮忙知道一下小弟!