From 2dc01bcfc18944ecb015e2fe7647676f7e428836 Mon Sep 17 00:00:00 2001 From: george82 Date: Wed, 24 May 2006 09:58:37 +0000 Subject: [PATCH] Small rfb::ScaledPixelBuffer class code improvements. Added Exception "rfb::ScaledPixelBuffer support only the true color pixel format". Removed the unnecessary method recreateScaledBuffer(). git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@583 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- rfb/ScaledPixelBuffer.cxx | 20 ++++++++++++-------- rfb/ScaledPixelBuffer.h | 10 ++++++---- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/rfb/ScaledPixelBuffer.cxx b/rfb/ScaledPixelBuffer.cxx index bf4612de..5892a97b 100644 --- a/rfb/ScaledPixelBuffer.cxx +++ b/rfb/ScaledPixelBuffer.cxx @@ -18,6 +18,7 @@ // -=- ScaledPixelBuffer.cxx +#include #include #include @@ -27,15 +28,16 @@ using namespace rdr; using namespace rfb; ScaledPixelBuffer::ScaledPixelBuffer(U8 **src_data_, int src_width_, - int src_height_, int scale) - : bpp(32), scaled_data(0), scale_ratio(1), scale(100) { + int src_height_, int scale, PixelFormat pf_) + : scaled_data(0), scale_ratio(1), scale(100) { 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), - bpp(32), scaled_data(0) { + pf(PixelFormat(32,24,0,1,255,255,255,0,8,16)), scaled_data(0) { } ScaledPixelBuffer::~ScaledPixelBuffer() { @@ -46,7 +48,13 @@ void ScaledPixelBuffer::setSourceBuffer(U8 **src_data_, int w, int h) { src_width = w; src_height = h; calculateScaledBufferSize(); - recreateScaledBuffer(); +} + +void ScaledPixelBuffer::setPF(const PixelFormat &pf_) { + if (pf_.depth != 24) { + throw rfb::Exception("rfb::ScaledPixelBuffer support only the true colour pixel format."); + } + pf = pf_; } void ScaledPixelBuffer::setScale(int scale_) { @@ -54,7 +62,6 @@ void ScaledPixelBuffer::setScale(int scale_) { scale = scale_; scale_ratio = double(scale) / 100; calculateScaledBufferSize(); - recreateScaledBuffer(); } } @@ -127,6 +134,3 @@ void ScaledPixelBuffer::calculateScaledBufferSize() { scaled_width = (int)ceil(src_width * scale_ratio); scaled_height = (int)ceil(src_height * scale_ratio); } - -void ScaledPixelBuffer::recreateScaledBuffer() { -} diff --git a/rfb/ScaledPixelBuffer.h b/rfb/ScaledPixelBuffer.h index 3b6aa7ef..d69f0ac1 100644 --- a/rfb/ScaledPixelBuffer.h +++ b/rfb/ScaledPixelBuffer.h @@ -24,6 +24,7 @@ #include #include +#include using namespace rdr; @@ -31,7 +32,7 @@ namespace rfb { class ScaledPixelBuffer { public: - ScaledPixelBuffer(U8 **data, int width, int height, int scale); + ScaledPixelBuffer(U8 **data, int width, int height, int scale, PixelFormat pf); ScaledPixelBuffer(); virtual ~ScaledPixelBuffer(); @@ -51,6 +52,9 @@ namespace rfb { // Set the new source buffer and its parameters void setSourceBuffer(U8 **src_data, int w, int h); + // Set the new pixel format + void setPF(const PixelFormat &pf); + // Set the new scale, in percent virtual void setScale(int scale); @@ -68,14 +72,12 @@ namespace rfb { // parameters (width, height, pixel format) void calculateScaledBufferSize(); - // Recreate the scaled pixel buffer - virtual void recreateScaledBuffer(); int src_width; int src_height; int scaled_width; int scaled_height; - int bpp; + PixelFormat pf; int scale; double scale_ratio; U8 **src_data; -- 2.39.5