diff options
author | george82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519> | 2006-02-12 11:28:53 +0000 |
---|---|---|
committer | george82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519> | 2006-02-12 11:28:53 +0000 |
commit | 97e5c23934ddc3d031c9333b36bba57262d68d2b (patch) | |
tree | d9a6e0c9c46febacba93226a5ff8a5a3cefce13b /rfb | |
parent | 01117ec1d11a64ff8bc3250bd2ea4cf479348973 (diff) | |
download | tigervnc-97e5c23934ddc3d031c9333b36bba57262d68d2b.tar.gz tigervnc-97e5c23934ddc3d031c9333b36bba57262d68d2b.zip |
Small ScaledPixelBuffer class improvements.
Added ScaledPixelBuffer::recreateScaledBuffer() method.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@487 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'rfb')
-rw-r--r-- | rfb/ScaledPixelBuffer.cxx | 10 | ||||
-rw-r--r-- | rfb/ScaledPixelBuffer.h | 2 |
2 files changed, 9 insertions, 3 deletions
diff --git a/rfb/ScaledPixelBuffer.cxx b/rfb/ScaledPixelBuffer.cxx index 0c4d5abf..962a54be 100644 --- a/rfb/ScaledPixelBuffer.cxx +++ b/rfb/ScaledPixelBuffer.cxx @@ -36,7 +36,7 @@ ScaledPixelBuffer::ScaledPixelBuffer(U8 **src_data_, int src_width_, scaled_width = (int)ceil(src_width * scale_ratio); scaled_height = (int)ceil(src_height * scale_ratio); - scaled_data = new U8[scaled_width * scaled_height * 4]; + recreateScaledBuffer(); } ScaledPixelBuffer::ScaledPixelBuffer() @@ -78,8 +78,7 @@ void ScaledPixelBuffer::setScale(int scale) { 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[scaled_width * scaled_height * 4]; + recreateScaledBuffer(); scaleRect(Rect(0, 0, scaled_width, scaled_height)); } @@ -145,3 +144,8 @@ void ScaledPixelBuffer::scaleRect(const Rect& r) { } } } + +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 588d102b..b4b5a8ec 100644 --- a/rfb/ScaledPixelBuffer.h +++ b/rfb/ScaledPixelBuffer.h @@ -69,6 +69,8 @@ namespace rfb { virtual void scaleRect(const Rect& r); protected: + virtual void recreateScaledBuffer(); + int src_width; int src_height; int scaled_width; |