From 01117ec1d11a64ff8bc3250bd2ea4cf479348973 Mon Sep 17 00:00:00 2001 From: george82 Date: Sun, 12 Feb 2006 11:03:48 +0000 Subject: [PATCH] Small ScaledPixelBuffer class improvements. Renamed width_ to scaled_width and height_ to scaled_height. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@486 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- rfb/ScaledPixelBuffer.cxx | 24 ++++++++++++------------ rfb/ScaledPixelBuffer.h | 14 +++++++------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/rfb/ScaledPixelBuffer.cxx b/rfb/ScaledPixelBuffer.cxx index 2aedb829..0c4d5abf 100644 --- a/rfb/ScaledPixelBuffer.cxx +++ b/rfb/ScaledPixelBuffer.cxx @@ -33,10 +33,10 @@ ScaledPixelBuffer::ScaledPixelBuffer(U8 **src_data_, int src_width_, scale_ratio = double(scale) / 100; - width_ = (int)ceil(src_width * scale_ratio); - height_ = (int)ceil(src_height * scale_ratio); + scaled_width = (int)ceil(src_width * scale_ratio); + scaled_height = (int)ceil(src_height * scale_ratio); - scaled_data = new U8[width_ * height_ * 4]; + scaled_data = new U8[scaled_width * scaled_height * 4]; } ScaledPixelBuffer::ScaledPixelBuffer() @@ -75,13 +75,13 @@ void ScaledPixelBuffer::setScale(int scale) { if (scale != scale_ratio * 100) { scale_ratio = double(scale) / 100; - width_ = (int)ceil(src_width * scale_ratio); - height_ = (int)ceil(src_height * scale_ratio); + scaled_width = (int)ceil(src_width * scale_ratio); + scaled_height = (int)ceil(src_height * scale_ratio); if (scaled_data) delete [] scaled_data; - scaled_data = new U8[width_ * height_ * 4]; + scaled_data = new U8[scaled_width * scaled_height * 4]; - scaleRect(Rect(0, 0, width_, height_)); + scaleRect(Rect(0, 0, scaled_width, scaled_height)); } } @@ -98,12 +98,12 @@ void ScaledPixelBuffer::scaleRect(const Rect& r) { // Calculate the scale boundaries x_start = vncmax(0, (r.tl.x-1) * scale_ratio); (x_start==int(x_start)) ? true : x_start=(int)(x_start+1); - x_end = vncmin(width_ - 1, r.br.x * scale_ratio); - ((x_end==int(x_end))&&(x_end!=width_-1)&&(x_end>0)) ? x_end-=1:x_end=(int)(x_end); + x_end = vncmin(scaled_width - 1, r.br.x * scale_ratio); + ((x_end==int(x_end))&&(x_end!=scaled_width-1)&&(x_end>0)) ? x_end-=1:x_end=(int)(x_end); y_start = vncmax(0, (r.tl.y-1) * scale_ratio); (y_start==int(y_start)) ? true : y_start=(int)(y_start+1); - y_end = vncmin(height_ - 1, r.br.y * scale_ratio); - ((y_end==int(y_end))&&(y_end!=height_-1)&&(y_end>0)) ? y_end-=1:y_end=(int)(y_end); + y_end = vncmin(scaled_height - 1, r.br.y * scale_ratio); + ((y_end==int(y_end))&&(y_end!=scaled_height-1)&&(y_end>0)) ? y_end-=1:y_end=(int)(y_end); // Scale the source rect to the destination image buffer using // bilinear interplation @@ -113,7 +113,7 @@ void ScaledPixelBuffer::scaleRect(const Rect& r) { c1_sub_dy = 1 - dy; for (int x = (int)x_start; x <= x_end; x++) { - ptr = &scaled_data[(x + y*width_) * 4]; + ptr = &scaled_data[(x + y*scaled_width) * 4]; i = (int)(dx = x / scale_ratio); dx -= i; diff --git a/rfb/ScaledPixelBuffer.h b/rfb/ScaledPixelBuffer.h index 4051a380..588d102b 100644 --- a/rfb/ScaledPixelBuffer.h +++ b/rfb/ScaledPixelBuffer.h @@ -36,16 +36,16 @@ namespace rfb { virtual ~ScaledPixelBuffer(); // Get width, height, number of pixels and scale - int width() const { return width_; } - int height() const { return height_; } - int area() const { return width_ * height_; } + int width() const { return scaled_width; } + int height() const { return scaled_height; } + int area() const { return scaled_width * scaled_height; } int scale() const { return (int)(scale_ratio * 100); } // Get rectangle encompassing this buffer // Top-left of rectangle is either at (0,0), or the specified point. - Rect getRect() const { return Rect(0, 0, width_, height_); } + Rect getRect() const { return Rect(0, 0, scaled_width, scaled_height); } Rect getRect(const Point& pos) const { - return Rect(pos, pos.translate(Point(width_, height_))); + return Rect(pos, pos.translate(Point(scaled_width, scaled_height))); } // Get the number of pixels per row in the actual pixel buffer data area @@ -69,10 +69,10 @@ namespace rfb { virtual void scaleRect(const Rect& r); protected: - int width_; - int height_; int src_width; int src_height; + int scaled_width; + int scaled_height; int bpp; double scale_ratio; U8 **src_data; -- 2.39.5