Any more thoughts on this issue that is highly important for me? :)
Thank you!
On 7/9/07, Sergey Kovalyov <[EMAIL PROTECTED]> wrote:
Hi All!
I'm still researching on how to organize screen sharing using Flex. Sure,
I can't implement such an advanced solution like Adobe Acrobat Connect.
Though I would like to share particular part of broadcaster application to
subscribers applications using BitmapData features and Socket connection.
Initially I create new Timer instance and subscribe on TimerEvent.TIMERevent.
Let's say my handler is called once a second.
If the handler is called first time, I capture the entire area using
BitmapData.draw() method. After that I capture area again and again and
compare it with the last result using BitmapData.compare() method. If
results are the same I do nothing, otherwise that method returns BitmapData
instance, where value in each point equals difference between new color and
previous color channel by channel.
The result is converted into the ByteArray using ByteArray.compress()
method and uncompress it using ByteArray.uncompress() method. After
decompressing I apply that difference using nested for ... loop:
_targetBitmap.bitmapData.lock();
*for* (*var* i : int = 0; i < differenceBitmapData.width; i++) {
*for* (*var* j : int = 0; j < differenceBitmapData.height; j++) {
*var* differenceColor : uint = differenceBitmapData.getPixel(i, j);
*if* (differenceColor != 0x000000) {
*var* targetColor : uint = _targetBitmap.bitmapData.getPixel(i, j);
*var* r1 : Number = (targetColor >> 16) & 0xFF;
*var* g1 : Number = (targetColor >> 8) & 0xFF;
*var* b1 : Number = targetColor & 0xFF;
*var* r2 : Number = (differenceColor >> 16) & 0xFF;
*var* g2 : Number = (differenceColor >> 8) & 0xFF;
*var* b2 : Number = differenceColor & 0xFF;
*var* r3 : Number = (r1 + r2) % (0xFF + 1);
*var* g3 : Number = (g1 + g2) % (0xFF + 1);
*var* b3 : Number = (b1 + b2) % (0xFF + 1);
targetColor = (r3 << 16) | (g3 << 8) | b3;
_targetBitmap.bitmapData.setPixel(i, j, targetColor);
}
}
}
_targetBitmap.bitmapData.unlock();
I have implemented this behaviour locally and it works. Initial bitmap
size and difference packages size depends on what happens on screen,
actually, but simple changes result in 2-10Kb after compression.
So the question is, do you consider this would work over the wire? Is this
algorithm effective enough? Do you know some better alternatives to
implement that?
Thank you in advance!
Sergey.