Exemple #1
0
// Send a set of rectangles
BOOL
vncClient::SendRectangles(const rfb::RectVector &rects)
{
	rfb::Rect rect;
	rfb::RectVector::const_iterator i;

	// Work through the list of rectangles, sending each one
	for (i=rects.begin();i!=rects.end();i++) {
		if (!SendRectangle(*i))
			return FALSE;
	}

	return TRUE;
}
Exemple #2
0
UINT vncEncodeXZ::EncodeBulkRects(const rfb::RectVector &allRects, BYTE *source, BYTE *dest, VSocket *outConn)
{
	if (allRects.empty()) {
		return TRUE;
	}

	xzos->SetCompressLevel(m_compresslevel);
	mos->clear();
	xzos->setUnderlying(mos);
	
	int nAllRects = allRects.size();

	rfb::RectVector::const_iterator i;

	for (i=allRects.begin();i!=allRects.end();i++) {
		const rfb::Rect& rect(*i);

		rfbRectangle rectangle;
		rectangle.x = Swap16IfLE(rect.tl.x-m_SWOffsetx);
		rectangle.y = Swap16IfLE(rect.tl.y-m_SWOffsety);
		rectangle.w = Swap16IfLE(rect.br.x - rect.tl.x);
		rectangle.h = Swap16IfLE(rect.br.y - rect.tl.y);

		xzos->writeBytes((const void*)&rectangle, sz_rfbRectangle);
	}
	
	for (i=allRects.begin();i!=allRects.end();i++) {
		const rfb::Rect& rect(*i);

		int x = rect.tl.x;
		int y = rect.tl.y;
		int w = rect.br.x - x;
		int h = rect.br.y - y;

		EncodeRect_Internal(source, x, y, w, h);
	}

	xzos->flush();

	const void* pDataBytes = mos->data();
	int nDataLength = mos->length();
	
	assert(nDataLength > 0);

	rfbFramebufferUpdateRectHeader surh;
	if( m_use_xzyw ){
		surh.encoding = Swap32IfLE(rfbEncodingXZYW);
	}else{
		surh.encoding = Swap32IfLE(rfbEncodingXZ);
	}

	int nAllRectsHigh = (nAllRects & 0xFFFF0000) >> 16;
	int nAllRectsLow = (nAllRects & 0x0000FFFF);

	int nDataLengthHigh = (nDataLength & 0xFFFF0000) >> 16;
	int nDataLengthLow = (nDataLength & 0x0000FFFF);

	surh.r.x = Swap16IfLE(nAllRectsHigh);
	surh.r.y = Swap16IfLE(nAllRectsLow);
	surh.r.w = Swap16IfLE(nDataLengthHigh);
	surh.r.h = Swap16IfLE(nDataLengthLow);

	UINT nTotalLength = 0;
	if (!outConn->SendExact((const char*)&surh, sz_rfbFramebufferUpdateRectHeader)) {
		return FALSE;
	}
	nTotalLength += sz_rfbFramebufferUpdateRectHeader;

	if (!outConn->SendExact((const char*)pDataBytes, nDataLength)) {
		return FALSE;
	}
	nTotalLength += nDataLength;

	return nDataLength > 0 ? TRUE : FALSE;
}