如何将 Image2 中与 Image1 中不同的部分提取并无闪烁的覆盖到 Image1 中相同的位置?(200分)

  • 主题发起人 wanggongqin
  • 开始时间
W

wanggongqin

Unregistered / Unconfirmed
GUEST, unregistred user!
我是想实现抓取屏幕变化的部分传送到网络的另一端,实现快速远程控制的目的。
其中这个技术是比较关键的部分。
即先比较两个图片不同的部分,然后提取这些不同的部分,
再将这些不同的部分无闪烁的覆盖到前一个图片的相同位置。

下面是我的测试代码,就差覆盖不同部分的代码了,怎么实现?

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, ExtDlgs, jpeg;

type
TForm1 = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Panel2: TPanel;
Label2: TLabel;
Label3: TLabel;
Image1: TImage;
Image2: TImage;
Button1: TButton;
Button2: TButton;
Button3: TButton;
opdImage: TOpenPictureDialog;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
if opdImage.Execute then
Image1.Picture.LoadFromFile(opdImage.FileName);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
if opdImage.Execute then
Image2.Picture.LoadFromFile(opdImage.FileName);
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
//怎么实现提取 Image2 中与 Image1 中不同的部分并无闪烁的覆盖到 Image1 中相同的位置。
end;

end.

----------------------------------------------------------------------------------------

object Label1: TLabel
Left = 8
Top = 40
Width = 36
Height = 14
Caption = '图片一'
end
object Label2: TLabel
Left = 344
Top = 40
Width = 36
Height = 14
Caption = '图片二'
end
object Label3: TLabel
Left = 8
Top = 12
Width = 286
Height = 14
Caption = '将图片二中与图片一中不同的部分反映到图片一中'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
Font.Name = 'Tahoma'
Font.Style = [fsBold]
ParentFont = False
end
object Panel2: TPanel
Left = 344
Top = 64
Width = 321
Height = 257
BevelOuter = bvLowered
TabOrder = 1
object Image2: TImage
Left = 1
Top = 1
Width = 319
Height = 255
Align = alClient
Stretch = True
end
end
object Button1: TButton
Left = 8
Top = 336
Width = 75
Height = 25
Caption = '载入(&Z)...'
TabOrder = 2
OnClick = Button1Click
end
object Button2: TButton
Left = 344
Top = 336
Width = 75
Height = 25
Caption = '载入(&R)...'
TabOrder = 3
OnClick = Button2Click
end
object Button3: TButton
Left = 8
Top = 376
Width = 89
Height = 25
Caption = '载入不同(&B)'
TabOrder = 4
OnClick = Button3Click
end
object Panel1: TPanel
Left = 8
Top = 64
Width = 321
Height = 257
BevelOuter = bvLowered
TabOrder = 0
object Image1: TImage
Left = 1
Top = 1
Width = 319
Height = 255
Hint = '可托动'#13#10'双击正常大小'
Align = alClient
ParentShowHint = False
ShowHint = True
Stretch = True
end
end
object opdImage: TOpenPictureDialog
Left = 112
Top = 200
end
//将以上窗体资源文本复制并在一个空白窗体上粘贴即可。
-------------------------------------------------------------------------------------
 
这样做只会更慢,直接copy数据是最快的.如果一定要判断不同,
用 图像1 xor 图像2,再用 lzw 压缩一下,再传输的话应该就变得很小了。
 
怎么 用 图像1 xor 图像2 啊?
 
图像1 的 buf xor 图像2 的buf,那么相同的地方就会变成00,压缩起来就小了。
 
图像的 buf 怎么引用,我比较菜,说的明确点好吧!
 
var
buf: pdwordarray;
i, j: integer;
begin
aa:= tbitmap.create;
aa.width:= 16;
aa.height:= 16;
aa.pixleformat:= pf32bit;

for i:= 0 to aa.height - 1 do
begin
buf:= aa.scanline;

for j:= 0 to aa.width - 1 do
buf[j]:= buf[j] xor 另外一个buf
end;
end;
 
但无论怎样,都不够直接传输的快.
 
-- 但无论怎样,都不够直接传输的快.
是吗?我听说 Radmin 就是取屏幕变化的部分进行传输的。
 
还不如拦截桌面变化区域重画的消息。只抓该区域的图传递。用钩子可以拦截到该消息
 
从传输角度来说,当然是传得越少越快,但是抓图,判断范围这个本来就要花许多时间,cmp,jz指令占的CPU周期远比mov 要多得多,个人认为是得不偿失.
 

Similar threads

I
回复
0
查看
621
import
I
I
回复
0
查看
575
import
I
I
回复
0
查看
724
import
I
顶部