服务端出现:Bitmap is not valid!代码:服务端:
procedure TCapLine.ServerSocket2ClientRead(Sender: TObject;
  Socket: TCustomWinSocket);
var
  s                 : string;
  sb                : TBitmap;
  Frame: TCommandFrame;
  ReplyStream: TMemoryStream;
  CurrentShot: TMemoryStream;
  MyFormat:Word;
  AData:THandle;      //临时句柄变量。
  APalette:HPALETTE;  //临时变量。
  size: Integer;
begin
  s := Socket.ReceiveText;
  if s = 'cap' then
  begin
    ms := TMemorystream.Create;
    sb := TBitmap.Create;
    try
        SampleGrabber.GetBitmap(sb);
        Clipboard.Open;
        Clipboard.Assign(sb);
        CurrentShot := TMemoryStream.Create;
        SaveBitmapToStream(CurrentShot, GetClipboardData(CF_BITMAP));
        CurrentShot.Position := 0;
        size:= CurrentShot.Size;        ms.WriteBuffer(size, Sizeof(size));
        ms.CopyFrom(CurrentShot, size);
        CurrentShot.Free;
        CloseClipboard;        ms.Position := 0;
   //     showmessage(IntToStr(ms.Size));
        socket.SendText(IntToStr(ms.Size));    finally      sb.Free;
    end;
  end;  if s = 'ready' then
  begin
    ms.Position := 0;
    socket.SendStream(ms);
  end;
  if s = 'exit' then
  begin
    FilterGraph.ClearGraph;
    FilterGraph.Active := false;
    ServerSocket2.Close;
  end;
end;客户端:procedure TCapShow.ClientSocket2Read(Sender: TObject;
  Socket: TCustomWinSocket);
var
  MyBuffer          : array[0..8192] of byte; {设置接收缓冲区}
  MyReceviceLength  : integer;
  sb                : TBitmap;
  Delta: Classes.TMemoryStream;
  JPG:  TJPEGImage;
begin
  if MySize = 0 then
  begin
    Mysize := StrToInt(socket.ReceiveText);
    if mysize=0 then
      socket.SendText('cap')
    else
      socket.SendText('ready');
  end
  else begin
    MyReceviceLength := Socket.ReceiveLength;
    Socket.ReceiveBuf(MyBuffer, MyReceviceLength);
    ms.Write(MyBuffer, MyReceviceLength);
    if ms.Size >= MySize then
    begin
      ms.Position :=0;
      jpg:= TJPEGImage.Create;
      try
        Delta := CreateBitmapDelta(nil, 0, ms);
        Jpg := Bmp2Jpeg(Delta);
        Image1.Picture.Bitmap.Assign(Jpg);
      finally
        Delta.Free;
        Jpg.Free;
        ms.Clear;
        MySize := 0;
        if bCap then
          Socket.SendText('cap')
        else begin
          Socket.SendText('exit');
          ClientSocket2.Close;
        end;
      end;
    end;  end;
end;