diff options
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(); |