// Encode the rectangle using Ultra compression inline UINT vncEncodeUltra::EncodeRect(BYTE *source, VSocket *outConn, BYTE *dest, const rfb::Rect &rect) { int totalSize = 0; int partialSize = 0; int maxLines; int linesRemaining; RECT partialRect; const int rectW = rect.br.x - rect.tl.x; const int rectH = rect.br.y - rect.tl.y; partialRect.right = rect.br.x; partialRect.left = rect.tl.x; partialRect.top = rect.tl.y; partialRect.bottom = rect.br.y; /* WBB: For testing purposes only! */ // vnclog.Print(LL_INTINFO, VNCLOG("rect.right=%d rect.left=%d rect.top=%d rect.bottom=%d\n"), rect.right, rect.left, rect.top, rect.bottom); if (rectW==0) return 0; if (rectH==0) return 0; maxLines = ( Ultra_MAX_SIZE(rectW) / rectW ); linesRemaining = rectH; while ( linesRemaining > 0 ) { int linesToComp; if ( maxLines < linesRemaining ) linesToComp = maxLines; else linesToComp = linesRemaining; partialRect.bottom = partialRect.top + linesToComp; /* WBB: For testing purposes only! */ // vnclog.Print(LL_INTINFO, VNCLOG("partialRect.right=%d partialRect.left=%d partialRect.top=%d partialRect.bottom=%d\n"), partialRect.right, partialRect.left, partialRect.top, partialRect.bottom); partialSize = EncodeOneRect( source,dest, partialRect,outConn ); totalSize += partialSize; linesRemaining -= linesToComp; partialRect.top += linesToComp; if (( linesRemaining > 0 ) && ( partialSize > 0 )) { // Send the encoded data outConn->SendExactQueue( (char *)dest, partialSize ); transmittedSize += partialSize; } } transmittedSize += partialSize; return partialSize; }
// Encode the rectangle using zlib compression inline UINT vncEncodeZlib::EncodeRect(BYTE *source, CurlSocket *outConn, BYTE *dest, const RECT &rect, int offx, int offy) { int totalSize = 0; int partialSize = 0; int maxLines; int linesRemaining; offsetx = offx; offsety = offy; RECT partialRect; const int rectW = rect.right - rect.left; const int rectH = rect.bottom - rect.top; partialRect.right = rect.right; partialRect.left = rect.left; partialRect.top = rect.top; partialRect.bottom = rect.bottom; /* WBB: For testing purposes only! */ // vnclog.Print(LL_INTINFO, VNCLOG("rect.right=%d rect.left=%d rect.top=%d rect.bottom=%d\n"), rect.right, rect.left, rect.top, rect.bottom); maxLines = ( ZLIB_MAX_SIZE(rectW) / rectW ); linesRemaining = rectH; while ( linesRemaining > 0 ) { int linesToComp; if ( maxLines < linesRemaining ) linesToComp = maxLines; else linesToComp = linesRemaining; partialRect.bottom = partialRect.top + linesToComp; /* WBB: For testing purposes only! */ // vnclog.Print(LL_INTINFO, VNCLOG("partialRect.right=%d partialRect.left=%d partialRect.top=%d partialRect.bottom=%d\n"), partialRect.right, partialRect.left, partialRect.top, partialRect.bottom); partialSize = EncodeOneRect( source, dest, partialRect ); totalSize += partialSize; linesRemaining -= linesToComp; partialRect.top += linesToComp; if (( linesRemaining > 0 ) && ( partialSize > 0 )) { // Send the encoded data outConn->SendQueued( (char *)dest, partialSize ); transmittedSize += partialSize; } } transmittedSize += partialSize; return partialSize; }