From: george82 Date: Sat, 29 Jul 2006 10:29:41 +0000 (+0000) Subject: ScaledDIBSectionBuffer class code improvements. Now we X-Git-Tag: v0.0.90~384^2~243 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=bf0adb358b0be339ca35fb0b984582883ba043da;p=tigervnc.git ScaledDIBSectionBuffer class code improvements. 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@640 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- diff --git a/win/rfb_win32/ScaledDIBSectionBuffer.cxx b/win/rfb_win32/ScaledDIBSectionBuffer.cxx index 7f14cceb..700e90b3 100644 --- a/win/rfb_win32/ScaledDIBSectionBuffer.cxx +++ b/win/rfb_win32/ScaledDIBSectionBuffer.cxx @@ -37,12 +37,12 @@ ScaledDIBSectionBuffer::~ScaledDIBSectionBuffer() { if (src_buffer) delete src_buffer; } -void ScaledDIBSectionBuffer::setScale(int scale_) { - if (scale_ == getScale()) return; +void ScaledDIBSectionBuffer::setScaleRatio(double scale_ratio_) { + if (scale_ratio == scale_ratio_) return; if (format.depth != 24) throw rfb::UnsupportedPixelFormatException(); - if (scale_ != 100) { + if (scale_ratio_ != 1) { scaling = true; if (!src_buffer) { src_buffer = new ManagedPixelBuffer(format, src_width, src_height); @@ -52,7 +52,7 @@ void ScaledDIBSectionBuffer::setScale(int scale_) { } else { scaling = false; } - ScaledPixelBuffer::setScale(scale_); + ScaledPixelBuffer::setScaleRatio(scale_ratio_); recreateScaledBuffer(); if (scaling) { scaleRect(Rect(0, 0, src_width, src_height)); diff --git a/win/rfb_win32/ScaledDIBSectionBuffer.h b/win/rfb_win32/ScaledDIBSectionBuffer.h index 7ec0b1f1..86771918 100644 --- a/win/rfb_win32/ScaledDIBSectionBuffer.h +++ b/win/rfb_win32/ScaledDIBSectionBuffer.h @@ -48,7 +48,8 @@ namespace rfb { virtual void setPF(const PixelFormat &pf); virtual void setSize(int w, int h); - virtual void setScale(int scale); + virtual void setScale(int scale) { setScaleRatio(double(scale)/100.0); }; + virtual void setScaleRatio(double scale_ratio); Rect getRect() const { return ScaledPixelBuffer::getRect(); } Rect getRect(const Point& pos) const { return ScaledPixelBuffer::getRect(pos); }