From d4344bec2cc1c16a4727ee795187f444bb7d21f5 Mon Sep 17 00:00:00 2001 From: george82 Date: Sat, 29 Jul 2006 10:27:19 +0000 Subject: [PATCH] ScaledPixelBuffer class code improvements. Remove scale parameter. Now we set the scale using setScaleRatio. It improve the accuracy of scaling operation. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@639 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- common/rfb/ScaledPixelBuffer.cxx | 11 +++++------ common/rfb/ScaledPixelBuffer.h | 7 ++++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/common/rfb/ScaledPixelBuffer.cxx b/common/rfb/ScaledPixelBuffer.cxx index e459b39b..e590580a 100644 --- a/common/rfb/ScaledPixelBuffer.cxx +++ b/common/rfb/ScaledPixelBuffer.cxx @@ -29,14 +29,14 @@ using namespace rfb; ScaledPixelBuffer::ScaledPixelBuffer(U8 **src_data_, int src_width_, int src_height_, int scale, PixelFormat pf_) - : scaled_data(0), scale_ratio(1), scale(100) { + : scaled_data(0), scale_ratio(1) { setSourceBuffer(src_data_, src_width_, src_height_); setPF(pf_); } ScaledPixelBuffer::ScaledPixelBuffer() - : src_data(0), src_width(0), src_height(0), scale_ratio(1), scale(100), + : src_data(0), src_width(0), src_height(0), scale_ratio(1), pf(PixelFormat(32,24,0,1,255,255,255,0,8,16)), scaled_data(0) { } @@ -55,10 +55,9 @@ void ScaledPixelBuffer::setPF(const PixelFormat &pf_) { pf = pf_; } -void ScaledPixelBuffer::setScale(int scale_) { - if (scale != scale_) { - scale = scale_; - scale_ratio = double(scale) / 100; +void ScaledPixelBuffer::setScaleRatio(double scale_ratio_) { + if (scale_ratio != scale_ratio_) { + scale_ratio = scale_ratio_; calculateScaledBufferSize(); } } diff --git a/common/rfb/ScaledPixelBuffer.h b/common/rfb/ScaledPixelBuffer.h index 17da5d6a..7ac31870 100644 --- a/common/rfb/ScaledPixelBuffer.h +++ b/common/rfb/ScaledPixelBuffer.h @@ -48,7 +48,8 @@ namespace rfb { int getSrcWidth() const { return src_width; } int getSrcHeight() const { return src_height; } int area() const { return scaled_width * scaled_height; } - int getScale() const { return scale; } + int getScale() const { return int(scale_ratio + 0.5); } + double getScaleRatio() const { return scale_ratio; } // Get rectangle encompassing this buffer // Top-left of rectangle is either at (0,0), or the specified point. @@ -64,7 +65,8 @@ namespace rfb { void setPF(const PixelFormat &pf); // Set the new scale, in percent - virtual void setScale(int scale); + virtual void setScale(int scale) { setScaleRatio(double(scale)/100.0); } + virtual void setScaleRatio(double scale_ratio); // Scale rect from the source image buffer to the destination buffer // using bilinear interpolation @@ -86,7 +88,6 @@ namespace rfb { int scaled_width; int scaled_height; PixelFormat pf; - int scale; double scale_ratio; U8 **src_data; U8 *scaled_data; -- 2.39.5