我重写了遍程序:
SERVER:-------------
procedure TForm1.serverClientRead(Sender: TObject;
Socket: TCustomWinSocket);
var strsize:integer;
buf
char;
x,y:integer;
l1, l2,l3: PByteArray;
Bmp1, Bmp2, Bmp3: TBitmap;
begin
strsize:=socket.ReceiveLength ;
if strsize=3 then
Bmp1 :=TBitmap.Create;
Bmp1.Assign(Image2.Picture.Bitmap);
Bmp2 :=TBitmap.Create;
Bmp2.Assign(Image1.Picture.Bitmap);
Bmp1.pixelformat := pf8bit;
Bmp2.pixelformat := pf8bit;
for y := 0 to Image1.Picture.Height-1 do
begin
l1 := Bmp1.ScanLine[y];
l2 := Bmp2.ScanLine[y];
for x:=0 to image2.Width -1 do
begin
if l1[x]<>l2[x] then
socket.SendBuf(l2[x],sizeof(l2[x]));
end;
end;
Bmp1.Free;
Bmp2.Free;
end;
------------------
CLIENT
-----------------------
procedure TForm1.ClientRead(Sender: TObject; Socket: TCustomWinSocket);
var l1,l2,l3
ByteArray;
x,y,p:integer;
strsize:integer;
bmp1:Tbitmap;
begin
strsize:=socket.ReceiveLength ;
bmp1:=Tbitmap.Create ;
Bmp1.Assign(Image1.Picture.Bitmap);
bmp1.PixelFormat :=pf8bit;
socket.ReceiveBuf(l2,strsize);
inc(p,strsize);
if p>=image1.Height then
begin
for y:=0 to image1.Height-1 do
begin
l1:=bmp1.ScanLine [y];
for x:=0 to image1.Width -1 do
if l1[x]<>l2[x] then
begin
l1[x]:=l2[x];
end;
end;
image1.Picture.Bitmap.Assign(bmp1);
bmp1.Free ;
end;
end;
--------------------------------
发现CLIENT的IMAGE1终于有了变化!可与SERVER的IMAGE2一点也不一样
好象和PIXELFORMAT有关,但我两边的PIXELFORMAT都设的一样啊(8BIT)
帮我看看有什么错?