diff options
author | george82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519> | 2006-03-27 15:10:43 +0000 |
---|---|---|
committer | george82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519> | 2006-03-27 15:10:43 +0000 |
commit | 1d78bd307ca4da879746cf480cd8657eb806f8aa (patch) | |
tree | 6d1fee0010f13b11724ee5ff13860cc93d34e6e9 /rfb | |
parent | edb5b24dda888c7bf936aad805720a36075c8b87 (diff) | |
download | tigervnc-1d78bd307ca4da879746cf480cd8657eb806f8aa.tar.gz tigervnc-1d78bd307ca4da879746cf480cd8657eb806f8aa.zip |
Added ScaledPixelBuffer::calculateScaleBoundary() in the rfb library.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@503 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'rfb')
-rw-r--r-- | rfb/ScaledPixelBuffer.cxx | 11 | ||||
-rw-r--r-- | rfb/ScaledPixelBuffer.h | 4 |
2 files changed, 15 insertions, 0 deletions
diff --git a/rfb/ScaledPixelBuffer.cxx b/rfb/ScaledPixelBuffer.cxx index 8e7430b4..b566ea4e 100644 --- a/rfb/ScaledPixelBuffer.cxx +++ b/rfb/ScaledPixelBuffer.cxx @@ -140,6 +140,17 @@ void ScaledPixelBuffer::scaleRect(const Rect& r) { } } +Rect ScaledPixelBuffer::calculateScaleBoundary(const Rect& r) { + static int x_start, y_start, x_end, y_end; + x_start = r.tl.x == 0 ? 0 : ceil((r.tl.x-1) * scale_ratio); + y_start = r.tl.y == 0 ? 0 : ceil((r.tl.y-1) * scale_ratio); + x_end = ceil(r.br.x * scale_ratio - 1); + x_end = x_end < scaled_width ? x_end + 1 : scaled_width; + y_end = ceil(r.br.y * scale_ratio - 1); + y_end = y_end < scaled_height ? y_end + 1 : scaled_height; + return Rect(x_start, y_start, x_end, y_end); +} + void ScaledPixelBuffer::recreateScaledBuffer() { if (scaled_data) delete [] scaled_data; scaled_data = new U8[scaled_width * scaled_height * (bpp / 8)]; diff --git a/rfb/ScaledPixelBuffer.h b/rfb/ScaledPixelBuffer.h index b4b5a8ec..8342a583 100644 --- a/rfb/ScaledPixelBuffer.h +++ b/rfb/ScaledPixelBuffer.h @@ -68,6 +68,10 @@ namespace rfb { // using bilinear interpolation virtual void scaleRect(const Rect& r); + // Calculate the scaled image rectangle which depend on the source + // image rectangle. + inline Rect calculateScaleBoundary(const Rect& r); + protected: virtual void recreateScaledBuffer(); |