//我的保存bmp的函数,保存512*512大小的图就会成功,
//但是保存513*513大小的,虽然保存了,但是打开不能显示???
function TWImage.SaveBMP(fileName : string) : Boolean;
var
bFile : file of Byte;
  bitmapFileHeader                                      : BMPFileHeader;
  bitmapInfoHeader                                     : BMPInfoHeader;
  pTemp : ByteArray;
  i : Integer;
  byteRGB : Byte;
begin
try
    AssignFile(bFile ,fileName );
    Rewrite (bFile);    //fiileheader
    bitmapFileHeader.lwSize := m_iWidth * m_iHeight * 3 + SizeOf(BMPFileHeader)
     + SizeOf(BMPInfoHeader);
    bitmapFileHeader.wType := BITMAP_ID;
    bitmapFileHeader.wReservedl := 0;
    bitmapFileHeader.wReservedh := 0;
    bitmapFileHeader.lwOffBits := SizeOf(BMPInfoHeader) + SizeOf(BMPFileHeader);    BlockWrite(bFile,bitmapFileHeader,SizeOf(BMPFileHeader));    //informationheader
    bitmapInfoHeader.lwSize :=  SizeOf(BMPInfoHeader);
    bitmapInfoHeader.wPlanes := 1;
    bitmapInfoHeader.wBitCount := 24;
    bitmapInfoHeader.lwCompression := 0;
    bitmapInfoHeader.lwSizeImage := m_iWidth * m_iHeight * 3;
    bitmapInfoHeader.lXPelsPerMeter := 0;
    bitmapInfoHeader.lYPelsPerMeter := 0;
    bitmapInfoHeader.lwClrUsed := 0;
    bitmapInfoHeader.lwClrImportant := 0;
    bitmapInfoHeader.lWidth := m_iWidth;
    bitmapInfoHeader.lHeight := m_iHeight;    BlockWrite(bFile,bitmapInfoHeader,SizeOf(BMPInfoHeader));    //原数据为RGB 还原为BGR
    SetLength(pTemp,m_iSize);
    Move(m_pImageData^,pTemp[0],m_iSize);
    i := 0;
    while i < bitmapInfoHeader.lwSizeImage do
    begin
      byteRGB := pTemp[i];
      pTemp[i] := pTemp[i+2];
      pTemp[i+2] := byteRGB;
      i := i + 3;
    end;    BlockWrite(bFile,pTemp[0],bitmapInfoHeader.lwSizeImage);
  finally
    CloseFile(bFile );
  end;  Result := True;
end;//这是我画到canvas上然后再保存的
bmp := TBitmap.Create;
  bmp.Width := imgsShow.Width;
  bmp.Height := imgsShow.Height;
  bmp.PixelFormat := pf24bit;
  BitBlt(bmp.Canvas.Handle,0,0,imgsShow.Width,imgsShow.Height,
   imgsShow.Canvas.Handle,0,0,SRCCOPY);
  bmp.SaveToFile('my.bmp');
  bmp.Free;
//这是用控件生成的bmp文件头
char data[80] = {
0x42, 0x4D, 0x3A, 0x0E, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00, 
0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x04, 0x0E, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 
0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF
};
//这是我的函数生成的bmp文件头
unsigned char data[64] = {
0x42, 0x4D, 0x39, 0x0C, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00, 
0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x03, 0x0C, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x1C, 0x88, 0x31, 0x5C, 0x01, 0x00, 0x00, 0x00, 0x00
};
不知怎么解决,急待(在线等)