views:

39

answers:

2

Hello, I'm trying to do a "remote desktop viewer". For this I need to send the user's desktop - and it's alot of infomation for sockets...(especially if the resolution is high and the information can approach to 5.3MB (1680X1050))

So I started to compress with GZIP stream and the 5.3MB became 500KB, then I added my own compress algorithm (I think it called RLE) - taking near pixels and write it in format that 1) have 256 >> 3 = 32 colors(for red,blue,green each) and write how many pixels in a row have the same color. + GZIP.

That brought the compression to be in average 60~65KB - up to 200KB and it can be also under 5000 if the screen is totally white.

Now - I thought (and haven't implemented yet) about passing the difference between each frame - for each line I write where the difference(between the pixels) is starting and how long is the difference. well, it can help - maybe I could get 30KB for each frame in average. but for sockets it's alot.

has anyone ever succeed to fit with this problem? (and how of course...)

A: 

You may wish to review the source code of a VNC.

Most VNC servers implement several different forms of compression.

Seth
+1  A: 

There are standard algorithms for compressing images: e.g. JPEG.

A further optimization is to know something about the image: for example on a desktop, items like the Windows Start button, and various application icons, and widgets on the title bar, are standard: so instead of sending their pixels values, you can send their logical identifiers.

Yes people have succeeded with this problem: people who write remote desktop software, including the open source VNC.

ChrisW
thank (all of)you very much, by the way, yes, I've tried JPG(and gif)... it becomes ~60KB when the quality is 0 and then the picture is not clear at all. thanks, I'll look on this "VNC" by the way - the idea of sending only the changed pixels is pretty much like you said - I won't send them each picture. thanks again.
Ohad
@Ohad JPG is "lossy" compression; there are lossless algorithms, including I think e.g. GIF and PNG.
ChrisW
GIF is lossing more data than JPG... PNG is maybe good(I haven't checked PNG) but it's not compressing enough.
Ohad
GF doesn't lose sharpness, but it does lose color depth: it's 8-bit color. Reducing the color depth in exchange for improving performance may be acceptable/beneficial to end-users of remote desktop.
ChrisW
@ChrisW: Normal windows that contain mostly text and UI controls only use a small number of colors, so it's possible to fit that into 256 colors. Of course it has to be done adaptively (only for rectangles of text or blank space)
rwong