BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Using the difference in an image

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics
View previous topic :: View next topic  
Author Message
Dave
Guest





PostPosted: Sat Feb 04, 2006 2:36 am    Post subject: Using the difference in an image Reply with quote



Hi

I need to implement some screen viewing functionality into my client server app. It will involve allowing the user on one machine to be able to allow upto 30 users on other machines in a LAN to 'view' their desktop, for demonstration purposes. Although there are plenty of 3rd party apps already doing this, I need the functionality built into mine!

The big problem to overcome seems to be the potential lag that will result in constantly sending the whole grabbed image.

My initial research has led me to believe that the best way to achieve this is to send the one full screen capture, grab another screen capture, and by comparing with the previous capture, transmit the differences only.

However, although I have found examples of comparing images using scanline, they normally return a true or false. How would I go about aquiring the 'difference' and re-creating the new image from the old image plus the difference?

Thanks for any help given

D
Back to top
Nils Haeck
Guest





PostPosted: Sat Feb 04, 2006 7:10 am    Post subject: Re: Using the difference in an image Reply with quote



Hi Dave,

You can go to the pixel level with the differences, so only send over pixels
that are different. One way to do this is to send the delta image (B - A).
The delta image will contain zeroes wherever B=A. You could use RLE encoding
to avoid sending large numbers of zeroes. You can also use some kind of PNG
encoding on the delta image, it will automatically also crunch the zeroes.

Another option is to divide the image in a lot of small blocks (eg. 16x16
pixels) and only send over blocks that contain differences (and a list of
block numbers with differences).

Hope that helps, Nils

"Dave" <deepthinker (AT) btinternet (DOT) com> schreef in bericht
news:43e3db06$1 (AT) newsgroups (DOT) borland.com...
Quote:

Hi

I need to implement some screen viewing functionality into my client
server app. It will involve allowing the user on one machine to be able to
allow upto 30 users on other machines in a LAN to 'view' their desktop,
for demonstration purposes. Although there are plenty of 3rd party apps
already doing this, I need the functionality built into mine!

The big problem to overcome seems to be the potential lag that will result
in constantly sending the whole grabbed image.

My initial research has led me to believe that the best way to achieve
this is to send the one full screen capture, grab another screen capture,
and by comparing with the previous capture, transmit the differences only.

However, although I have found examples of comparing images using
scanline, they normally return a true or false. How would I go about
aquiring the 'difference' and re-creating the new image from the old image
plus the difference?

Thanks for any help given

D
Back to top
dave
Guest





PostPosted: Sat Feb 04, 2006 4:02 pm    Post subject: Re: Using the difference in an image Reply with quote



Hi

Cheers Smile That was a stupid mistake. I think I also had a problem due to my pixelformat not being pf32bit. The original image was only 24bit.

Thanks again



"Nils Haeck" <bla (AT) bla (DOT) com> wrote:
Quote:
You set the width and the height of the delta image from the original
*before* you've loaded the original, so it will be set to zero. Of course
then it goes wrong.

Nils

"dave" <deepthinker (AT) btinternet (DOT) com> schreef in bericht
news:43e4b096$1 (AT) newsgroups (DOT) borland.com...

Hi

I've been looking for examples of how to implement a delta image as you
suggested, but have had little luck. I tried combining a few examples i
found to produce a test project.

So I've been trying to implement the delta image by:

procedure TForm1.Button3Click(Sender: TObject);
var
x,row : Integer;
original,new,delta : TBitMap;
PtrOrigRow,PtrNewRow : PByte;
y : Integer;
LineO,lineN,LineD : PRGB32Array;
begin
// PixelFormat := pf32bit;
original := TBitMap.create;
new:= TBitMap.create;
delta:= TBitMap.create;
delta.PixelFormat:=original.PixelFormat;
delta.Width:=original.Width;
delta.Height:=original.Height;
try
original.LoadFromFile('C:\Program Files\Common Files\Borland
Shared\Images\Splash\256color\factory.bmp');
new.LoadFromFile('C:\Program Files\Common Files\Borland
Shared\Images\Splash\256color\factory1.bmp');
Canvas.Draw(0,0,original);
canvas.Draw(400,0,new);

for y := 0 to original.Height - 1 do
begin
LineO := original.Scanline[y];
LineN := new.Scanline[y];
LineD:=delta.ScanLine[y];
for x := 0 to Width - 1 do
begin
LineD[x].B:=LineN[x].B -LineO[x].B;
LineD[x].G:=LineN[x].G -LineO[x].G;
LineD[x].R:=LineN[x].R -LineO[x].R;
LineD[x].A:=LineN[x].A -LineO[x].A;
end;
end;
Canvas.Draw(200,400,delta);
finally
Canvas.Draw(200,400,delta);
original.Free;
new.Free;
delta.Free;
end;

end;

However this causes an exception error at line:
LineD:=delta.ScanLine[y];

Can you point out where I am going wrong?

Many thanks
Pete

"Nils Haeck" <bla (AT) bla (DOT) com> wrote:
Hi Dave,

You can go to the pixel level with the differences, so only send over
pixels
that are different. One way to do this is to send the delta image (B - A).
The delta image will contain zeroes wherever B=A. You could use RLE
encoding
to avoid sending large numbers of zeroes. You can also use some kind of
PNG
encoding on the delta image, it will automatically also crunch the zeroes.

Another option is to divide the image in a lot of small blocks (eg. 16x16
pixels) and only send over blocks that contain differences (and a list of
block numbers with differences).

Hope that helps, Nils

"Dave" <deepthinker (AT) btinternet (DOT) com> schreef in bericht
news:43e3db06$1 (AT) newsgroups (DOT) borland.com...

Hi

I need to implement some screen viewing functionality into my client
server app. It will involve allowing the user on one machine to be able
to
allow upto 30 users on other machines in a LAN to 'view' their desktop,
for demonstration purposes. Although there are plenty of 3rd party apps
already doing this, I need the functionality built into mine!

The big problem to overcome seems to be the potential lag that will
result
in constantly sending the whole grabbed image.

My initial research has led me to believe that the best way to achieve
this is to send the one full screen capture, grab another screen
capture,
and by comparing with the previous capture, transmit the differences
only.

However, although I have found examples of comparing images using
scanline, they normally return a true or false. How would I go about
aquiring the 'difference' and re-creating the new image from the old
image
plus the difference?

Thanks for any help given

D





Back to top
Nils Haeck
Guest





PostPosted: Sat Feb 04, 2006 4:02 pm    Post subject: Re: Using the difference in an image Reply with quote

You set the width and the height of the delta image from the original
*before* you've loaded the original, so it will be set to zero. Of course
then it goes wrong.

Nils

"dave" <deepthinker (AT) btinternet (DOT) com> schreef in bericht
news:43e4b096$1 (AT) newsgroups (DOT) borland.com...
Quote:

Hi

I've been looking for examples of how to implement a delta image as you
suggested, but have had little luck. I tried combining a few examples i
found to produce a test project.

So I've been trying to implement the delta image by:

procedure TForm1.Button3Click(Sender: TObject);
var
x,row : Integer;
original,new,delta : TBitMap;
PtrOrigRow,PtrNewRow : PByte;
y : Integer;
LineO,lineN,LineD : PRGB32Array;
begin
// PixelFormat := pf32bit;
original := TBitMap.create;
new:= TBitMap.create;
delta:= TBitMap.create;
delta.PixelFormat:=original.PixelFormat;
delta.Width:=original.Width;
delta.Height:=original.Height;
try
original.LoadFromFile('C:\Program Files\Common Files\Borland
Shared\Images\Splash\256color\factory.bmp');
new.LoadFromFile('C:\Program Files\Common Files\Borland
Shared\Images\Splash\256color\factory1.bmp');
Canvas.Draw(0,0,original);
canvas.Draw(400,0,new);

for y := 0 to original.Height - 1 do
begin
LineO := original.Scanline[y];
LineN := new.Scanline[y];
LineD:=delta.ScanLine[y];
for x := 0 to Width - 1 do
begin
LineD[x].B:=LineN[x].B -LineO[x].B;
LineD[x].G:=LineN[x].G -LineO[x].G;
LineD[x].R:=LineN[x].R -LineO[x].R;
LineD[x].A:=LineN[x].A -LineO[x].A;
end;
end;
Canvas.Draw(200,400,delta);
finally
Canvas.Draw(200,400,delta);
original.Free;
new.Free;
delta.Free;
end;

end;

However this causes an exception error at line:
LineD:=delta.ScanLine[y];

Can you point out where I am going wrong?

Many thanks
Pete

"Nils Haeck" <bla (AT) bla (DOT) com> wrote:
Hi Dave,

You can go to the pixel level with the differences, so only send over
pixels
that are different. One way to do this is to send the delta image (B - A).
The delta image will contain zeroes wherever B=A. You could use RLE
encoding
to avoid sending large numbers of zeroes. You can also use some kind of
PNG
encoding on the delta image, it will automatically also crunch the zeroes.

Another option is to divide the image in a lot of small blocks (eg. 16x16
pixels) and only send over blocks that contain differences (and a list of
block numbers with differences).

Hope that helps, Nils

"Dave" <deepthinker (AT) btinternet (DOT) com> schreef in bericht
news:43e3db06$1 (AT) newsgroups (DOT) borland.com...

Hi

I need to implement some screen viewing functionality into my client
server app. It will involve allowing the user on one machine to be able
to
allow upto 30 users on other machines in a LAN to 'view' their desktop,
for demonstration purposes. Although there are plenty of 3rd party apps
already doing this, I need the functionality built into mine!

The big problem to overcome seems to be the potential lag that will
result
in constantly sending the whole grabbed image.

My initial research has led me to believe that the best way to achieve
this is to send the one full screen capture, grab another screen
capture,
and by comparing with the previous capture, transmit the differences
only.

However, although I have found examples of comparing images using
scanline, they normally return a true or false. How would I go about
aquiring the 'difference' and re-creating the new image from the old
image
plus the difference?

Thanks for any help given

D



Back to top
dave
Guest





PostPosted: Sat Feb 04, 2006 4:02 pm    Post subject: Re: Using the difference in an image Reply with quote

Hi

I've been looking for examples of how to implement a delta image as you suggested, but have had little luck. I tried combining a few examples i found to produce a test project.

So I've been trying to implement the delta image by:

procedure TForm1.Button3Click(Sender: TObject);
var
x,row : Integer;
original,new,delta : TBitMap;
PtrOrigRow,PtrNewRow : PByte;
y : Integer;
LineO,lineN,LineD : PRGB32Array;
begin
// PixelFormat := pf32bit;
original := TBitMap.create;
new:= TBitMap.create;
delta:= TBitMap.create;
delta.PixelFormat:=original.PixelFormat;
delta.Width:=original.Width;
delta.Height:=original.Height;
try
original.LoadFromFile('C:\Program Files\Common Files\Borland Shared\Images\Splash\256color\factory.bmp');
new.LoadFromFile('C:\Program Files\Common Files\Borland Shared\Images\Splash\256color\factory1.bmp');
Canvas.Draw(0,0,original);
canvas.Draw(400,0,new);

for y := 0 to original.Height - 1 do
begin
LineO := original.Scanline[y];
LineN := new.Scanline[y];
LineD:=delta.ScanLine[y];
for x := 0 to Width - 1 do
begin
LineD[x].B:=LineN[x].B -LineO[x].B;
LineD[x].G:=LineN[x].G -LineO[x].G;
LineD[x].R:=LineN[x].R -LineO[x].R;
LineD[x].A:=LineN[x].A -LineO[x].A;
end;
end;
Canvas.Draw(200,400,delta);
finally
Canvas.Draw(200,400,delta);
original.Free;
new.Free;
delta.Free;
end;

end;

However this causes an exception error at line:
LineD:=delta.ScanLine[y];

Can you point out where I am going wrong?

Many thanks
Pete

"Nils Haeck" <bla (AT) bla (DOT) com> wrote:
Quote:
Hi Dave,

You can go to the pixel level with the differences, so only send over pixels
that are different. One way to do this is to send the delta image (B - A).
The delta image will contain zeroes wherever B=A. You could use RLE encoding
to avoid sending large numbers of zeroes. You can also use some kind of PNG
encoding on the delta image, it will automatically also crunch the zeroes.

Another option is to divide the image in a lot of small blocks (eg. 16x16
pixels) and only send over blocks that contain differences (and a list of
block numbers with differences).

Hope that helps, Nils

"Dave" <deepthinker (AT) btinternet (DOT) com> schreef in bericht
news:43e3db06$1 (AT) newsgroups (DOT) borland.com...

Hi

I need to implement some screen viewing functionality into my client
server app. It will involve allowing the user on one machine to be able to
allow upto 30 users on other machines in a LAN to 'view' their desktop,
for demonstration purposes. Although there are plenty of 3rd party apps
already doing this, I need the functionality built into mine!

The big problem to overcome seems to be the potential lag that will result
in constantly sending the whole grabbed image.

My initial research has led me to believe that the best way to achieve
this is to send the one full screen capture, grab another screen capture,
and by comparing with the previous capture, transmit the differences only.

However, although I have found examples of comparing images using
scanline, they normally return a true or false. How would I go about
aquiring the 'difference' and re-creating the new image from the old image
plus the difference?

Thanks for any help given

D


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.