SCANLINE怎么用?(50分)

我要的只是不同点~传真副图用流就可以了呀~
哎~~
我真的是没法子了~
 
你先把整副图传过来,变成bitmap,然后直接用我给出的那段函数就可以了,这样不是简单吗?
 
把整副图传过来不就失去判断点的意义了吗?
还不如直接COPYRECT
 
我重写了遍程序:
SERVER:-------------
procedure TForm1.serverClientRead(Sender: TObject;
Socket: TCustomWinSocket);
var strsize:integer;
buf:pchar;
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:pByteArray;
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)
帮我看看有什么错?
 
改成pf32bit试试
 
怎么个不一样法?是一片白,还是...
 
很多颜色,一条一条的
 
仿照下面的,加一个bmp3和l3,不要直接对l1操作,试试。

//TBitmap.ScanLine得到位图某行的指针.
procedure TForm1.Button2Click(Sender: TObject);
var
l1, l2, l3: PByteArray;
y, x: integer;
b: boolean;
Bmp1, Bmp2, Bmp3: TBitmap;
begin

Bmp1 :=TBitmap.Create;
Bmp1.Assign(Image1.Picture.Bitmap);
Bmp2 :=TBitmap.Create;
Bmp2.Assign(Image2.Picture.Bitmap);
Bmp3 :=TBitmap.Create;
Bmp3.Width := Bmp1.Width;
Bmp3.Height := Bmp1.Height;

Bmp1.pixelformat := pf32bit;
Bmp2.pixelformat := pf32bit;
Bmp3.pixelformat := pf32bit;

for y := 0 to Image1.Picture.Height-1 do
begin
l1 := Bmp1.ScanLine[y];
l2 := Bmp2.ScanLine[y];
l3 := Bmp3.ScanLine[y];
b := false;
for x := 0 to Image2.Picture.Width-1 do
begin
if l1[x]<>l2[x] then
begin
l3[x] := l1[x] and l2[x];
end
else l3[x] := l1[x];
end;
end;

Image2.Picture.Bitmap.Assign(Bmp3);
Bmp1.Free;
Bmp2.Free;
Bmp3.Free;

end;
 
不行啊,变化得更快了~

图象还是老样子~
 
你把代码粘贴到DELPHI里帮我调试一下看看~谢了
 
需要确定是网络传输的问题,还是Client端程序处理的问题。
建议先不要传到Client,直接在Server端处理图片,看是否正确。如果正确,再看你传到
Client端的数据和你在Server端得的数据是否一致。

是比较麻烦:(
 
我测试过了,SEVER端转换完全正确
 
传到Client端的数据和你在Server端得的数据是否一致(我指l2)?
 
可是我用
else l3[x] := l1[x];
socket.SendBuf(l3[x],sizeof(l3[x]));
end;
end;
image1.Picture.Bitmap.Assign(bmp3);
IMAGE1好象没转换,但用原来的L1[X]=L2[X] 。。。。。。ASSIGN(BMP1)是可以的
 
怎么判断是否一致?
 
你可以单步调试,
或者把它打印出来:
s: string;

s := '';
for i := 0 to length(l2)-1 do s := s+ format('/%x',[l2]);
ShowMessage(s);
 
在SERVER得到/FF/FF/1A/1A/1A/1A/1A/1A
在CLIENT一执行,又在IF L1[X]《》L2[X]那出错了~~真怪
 
在Client端,在“IF L1[X]《》L2[X]”之前把l2打印出来,看是多少。
 
好象还是出错~~

大哥帮我调试一下吧,我先走了~
 

Similar threads

回复
0
查看
577
不得闲
回复
0
查看
574
不得闲
回复
0
查看
665
不得闲
S
回复
0
查看
664
swish
S
顶部