 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Rafael Colucci Guest
|
Posted: Mon May 09, 2005 5:25 pm Post subject: ScreenShot streaming |
|
|
Hello
I need to make a programa like Vnc, Anywhere ... I have some machines that I
would like to monitor ... but my program only need to see what my users are
doing ...
I wrote a program that do a screenshot and send to my machine with Indy ...
but it is very slow, because a screenshot have 3MB of length ...
I already tried to compact, or send with jpg ... but is very slow compact a
screenshot ...
I need a real time program, with maximum 1 second of lag ... Anybody can
help me?
Rafael Colucci
|
|
| Back to top |
|
 |
Avatar Zondertau Guest
|
Posted: Mon May 09, 2005 5:29 pm Post subject: Re: ScreenShot streaming |
|
|
| Quote: | I need to make a programa like Vnc, Anywhere ... I have some machines
that I would like to monitor ... but my program only need to see what
my users are doing ...
I wrote a program that do a screenshot and send to my machine with
Indy ... but it is very slow, because a screenshot have 3MB of
length ... I already tried to compact, or send with jpg ... but is
very slow compact a screenshot ...
I need a real time program, with maximum 1 second of lag ... Anybody
can help me?
|
ISTM you'll need to send only the part of the screen that has actually
changed. Most frames will be identical, so in those cases no data needs
to be sent. If the screen's content does change all of the different
pixels are probably contained in only a few small rectangles.
You should let your program remember the previous frame, so that it can
compare the two and need only send pixels that have actually changed.
If you also add compression (preferably lossless) to this you'll
seriously reduce the data stream.
|
|
| Back to top |
|
 |
Rafael Colucci Guest
|
Posted: Mon May 09, 2005 5:53 pm Post subject: Re: ScreenShot streaming |
|
|
Yes ... it´s exactly what i´m doing!! I created a buffer of parts to the
screen and before send I compare the frames and send only the frames changed
.... But, in most cases, the user works with a program maximized .... in this
case the buffer not work ... Only if a set a buffer to a number very big ...
in this case, the memory of the users machine will be full ...
Rafael Colucci
"Avatar Zondertau" <avatarzt (AT) gmail (DOT) com> escreveu na mensagem
news:427f9de1$1 (AT) newsgroups (DOT) borland.com...
| Quote: | I need to make a programa like Vnc, Anywhere ... I have some machines
that I would like to monitor ... but my program only need to see what
my users are doing ...
I wrote a program that do a screenshot and send to my machine with
Indy ... but it is very slow, because a screenshot have 3MB of
length ... I already tried to compact, or send with jpg ... but is
very slow compact a screenshot ...
I need a real time program, with maximum 1 second of lag ... Anybody
can help me?
ISTM you'll need to send only the part of the screen that has actually
changed. Most frames will be identical, so in those cases no data needs
to be sent. If the screen's content does change all of the different
pixels are probably contained in only a few small rectangles.
You should let your program remember the previous frame, so that it can
compare the two and need only send pixels that have actually changed.
If you also add compression (preferably lossless) to this you'll
seriously reduce the data stream.
|
|
|
| Back to top |
|
 |
Michael Mattsson Guest
|
Posted: Tue May 10, 2005 3:47 am Post subject: Re: ScreenShot streaming |
|
|
Maximized windows or not, that shouldn't make much of a difference - as you
only send the section of the screen that has changed from the last cache
save.
If you use a lower color quality (use 8bit instead of 16/24/32 bit), send
only updated portions, then I don't see why there would be any memory or
speed issues.
Even if your users all used 1600x1200 resolutions, proper cache comparisons
should make your app very speedy, and fairly memory efficient.
You could even use UDP packets to cut down on the TCP overhead.
cheers,
Michael
"Rafael Colucci" wrote:
| Quote: | Yes ... it´s exactly what i´m doing!! I created a buffer of parts to the
screen and before send I compare the frames and send only the frames
changed
... But, in most cases, the user works with a program maximized .... in
this
case the buffer not work ... Only if a set a buffer to a number very big
...
in this case, the memory of the users machine will be full ...
Rafael Colucci
|
|
|
| Back to top |
|
 |
Ronaldo Souza Guest
|
Posted: Tue May 10, 2005 5:52 am Post subject: Re: ScreenShot streaming |
|
|
Just adding to what previous posters already said:
- Work with 256 colors, IMHO this color depth allows for simple
algorithms without significant loss of image quality. To create an
optimal 256 colors palette, use the "ReduceColors" function from
TGIFImage (http://finn.mobilixnet.dk/delphi/gifimaged7c.zip) or the
CreateOptimizedPaletteForSingleBitmap from the unit "PaletteLibrary"
that comes in "ShowDemoOne.zip"
(http://www.efg2.com/Lab/Graphics/Colors/ShowDemoOne.ZIP)
- Let the user adjust the CompressionQuality of TJPEGImage.
- Set the JPEGImage.PixelFormat to jf8Bit.
- If you need resize/resample, google for "Lanczos3". It gives great
results, although a bit slower than other algorithms.
- My $0.02 pseudo-code:
OBS: BMPs supposed to be pf8bit and the same size.
var
BMP1,BMP2 : TBitMap; //previous and current frame
SL1,SL2 : PByteArray;
x,y : integer;
begin
GetNextFrame(BMP1);
WriteToYourStream(BMP1);
While ThereAreFramesToSend do
begin
GetNextFrame(BMP2);
for y := 0 to BMP1.Height-1 do
begin
SL1 := BMP1.ScanLine[y];
SL2 := BMP2.ScanLine[y];
for x := 0 to BMP1.Width-1 do
begin
if (SL1^[x] <> SL2^[x]) then
begin
//found a difference: send the line number and data
//the receiver should refresh just this line or buffer
//a bunch of lines and then refresh.
WriteToYourStream(y,SizeOf(y));
WriteToYourStream(SL2^,BMP1.Width);
break; //skip to next line
end;
end;
end;
PreviousFrame <- CurrentFrame;
end;
end;
HTH,
Ronaldo
|
|
| Back to top |
|
 |
Rafael Colucci Guest
|
Posted: Tue May 10, 2005 12:54 pm Post subject: Re: ScreenShot streaming |
|
|
Ronaldo
So ... I do a screenshot with a user resolution, but with a 256 color bitmap
with a palette created with CreateOptimizedPaletteForSingleBitmap ... is
this? My bitmap will be lesser with this?
A resolucao da tela do usuario normalmente e de 16 bits pra cima .. entao eu
crio um btmap com 256 cores e com a paleta otimizada pelas funcoes que vc me
passou e vou ter um bitmap sem muita perda de qualidade e com uma tamanho
menor? E isto? E porque vc propos reduzir o tamanho to bitmap?
Rafael Colucci
"Ronaldo Souza" <nospam (AT) nospam (DOT) org> escreveu na mensagem
news:42804C15.3060503 (AT) nospam (DOT) org...
| Quote: | Just adding to what previous posters already said:
- Work with 256 colors, IMHO this color depth allows for simple
algorithms without significant loss of image quality. To create an
optimal 256 colors palette, use the "ReduceColors" function from
TGIFImage (http://finn.mobilixnet.dk/delphi/gifimaged7c.zip) or the
CreateOptimizedPaletteForSingleBitmap from the unit "PaletteLibrary"
that comes in "ShowDemoOne.zip"
(http://www.efg2.com/Lab/Graphics/Colors/ShowDemoOne.ZIP)
- Let the user adjust the CompressionQuality of TJPEGImage.
- Set the JPEGImage.PixelFormat to jf8Bit.
- If you need resize/resample, google for "Lanczos3". It gives great
results, although a bit slower than other algorithms.
- My $0.02 pseudo-code:
OBS: BMPs supposed to be pf8bit and the same size.
var
BMP1,BMP2 : TBitMap; //previous and current frame
SL1,SL2 : PByteArray;
x,y : integer;
begin
GetNextFrame(BMP1);
WriteToYourStream(BMP1);
While ThereAreFramesToSend do
begin
GetNextFrame(BMP2);
for y := 0 to BMP1.Height-1 do
begin
SL1 := BMP1.ScanLine[y];
SL2 := BMP2.ScanLine[y];
for x := 0 to BMP1.Width-1 do
begin
if (SL1^[x] <> SL2^[x]) then
begin
//found a difference: send the line number and data
//the receiver should refresh just this line or buffer
//a bunch of lines and then refresh.
WriteToYourStream(y,SizeOf(y));
WriteToYourStream(SL2^,BMP1.Width);
break; //skip to next line
end;
end;
end;
PreviousFrame <- CurrentFrame;
end;
end;
HTH,
Ronaldo
|
|
|
| Back to top |
|
 |
Ronaldo Souza Guest
|
Posted: Tue May 10, 2005 6:54 pm Post subject: Re: ScreenShot streaming |
|
|
Rafael Colucci wrote:
| Quote: |
So ... I do a screenshot with a user resolution, but with a 256 color bitmap
with a palette created with CreateOptimizedPaletteForSingleBitmap ... is
this? My bitmap will be lesser with this?
Yes. You take a screenshot with the user's resolution (ex. 800x600) and |
color depth (ex. 24 bits) then reduce the color depth to 8 bits. The
reason the image will be smaller is that, for instance, in 24 bit mode,
each pixel occupies 3 bytes and in 8 bit mode, just one. If this
reduction is not enough for your needs, you might have to resample the
image to a smaller size (keeping the aspect ratio, ex. 400x300). For
this, I suggest the Lanczos3 algorithm. Just search google groups for
"delphi Lanczos3".
Did you understand the pseudo-code in my previous e-mail? The idea is to
send just the lines in the current frame that are different from the
previous frame. It's rather crude, but it might be efficient since if a
line has one different pixel, it is very likely, under normal
circumstances, to have many more, so why bother searching? Just send the
whole line. The key is the ScanLine property which points to each line
of the bitmap and is *much* faster than Pixels[x,y]. Take a good look at
the tech note "Manipulating Pixels With Delphi's ScanLine Property" at
Earl F. Glynn's Computer Lab site:
http://www.efg2.com/Lab/ImageProcessing/Scanline.htm.
By the way, this site probably has everything you will ever need
regarding graphics. It's a *great* reference.
I'm by no means an expert, but if you want, I'll try to help you. Since
this is an international group, it is not very polite to use any
language that can't be understood by the majority of the members. If you
want to keep this conversation in portuguese, please contact me directly
at hwrs at mcsoft dot com dot br. As long as it is ok to post the
results (if any...) to the group.
Good luck,
Ronaldo
|
|
| Back to top |
|
 |
|
|
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
|
|