recreateBuffers();
}
+void ScaledDIBSectionBuffer::setScaleWindowSize(int width, int height) {
+ if (scaled_width == width && scaled_height == height) return;
+
+ freeWeightTabs();
+
+ scaled_width = width_ = width;
+ scaled_height = height_ = height;
+
+ if (scaled_width == src_width && scaled_height == src_height) scaling = false;
+ else scaling = true;
+ scale_ratio_x = (double)scaled_width / src_width;
+ scale_ratio_y = (double)scaled_height / src_height;
+ scale = (int)(scale_ratio_x * 100);
+
+ // FIXME:
+ // Calculate the scale weight tabs must be in the ScalePixelBuffer class
+ scaleFilters.makeWeightTabs(scaleFilterID, src_width, scaled_width, &xWeightTabs);
+ scaleFilters.makeWeightTabs(scaleFilterID, src_height, scaled_height, &yWeightTabs);
+
+ recreateBuffers();
+}
+
void ScaledDIBSectionBuffer::recreateScaledBuffer() {
- calculateScaledBufferSize();
if (scaling && memcmp(&(DIBSectionBuffer::getPF()), &RGB24, sizeof(PixelFormat)) != 0) {
DIBSectionBuffer::setPF(RGB24);
} else if (!scaling && (memcmp(&(DIBSectionBuffer::getPF()), &pf, sizeof(PixelFormat)) != 0)){
virtual const PixelFormat& getScaledPixelFormat() const { return getPF(); }
virtual void setSize(int w, int h);
virtual void setScale(int scale);
+ virtual void setScaleWindowSize(int width, int height);
virtual void calculateScaledBufferSize();
window->setMenuKey(options.menuKey);
window->setDisableWinKeys(options.disableWinKeys);
window->setShowToolbar(options.showToolbar);
+ window->printScale();
if (options.autoScaling) {
window->setAutoScaling(true);
} else {
#include <windows.h>
#include <commctrl.h>
+#include <math.h>
#include <rfb/Configuration.h>
#include <rfb/LogWriter.h>
#include <rfb_win32/WMShatter.h>
buffer->setScale(scale_);
if (isToolbarEnabled()) refreshToolbarButtons();
if (!isAutoScaling() && !isFullscreen()) resizeDesktopWindowToBuffer();
- char *newTitle = new char[strlen(desktopName)+20];
- sprintf(newTitle, "%s @ %i%%", desktopName, getDesktopScale());
- SetWindowText(handle, TStr(newTitle));
- delete [] newTitle;
+ printScale();
InvalidateRect(frameHandle, 0, FALSE);
}
client_size = Rect(r.left, r.top, r.right, r.bottom);
}
if (resized_aspect_corr > aspect_corr) {
- scale_ratio = double(client_size.height()) / buffer->getSrcHeight();
+ scale_ratio = (double)client_size.height() / buffer->getSrcHeight();
+ buffer->setScaleWindowSize(ceil(buffer->getSrcWidth()*scale_ratio), client_size.height());
} else {
- scale_ratio = double(client_size.width()) / buffer->getSrcWidth();
+ scale_ratio = (double)client_size.width() / buffer->getSrcWidth();
+ buffer->setScaleWindowSize(client_size.width(), ceil(buffer->getSrcHeight()*scale_ratio));
}
- setDesktopScale(int(scale_ratio * 100));
+ printScale();
+ InvalidateRect(frameHandle, 0, FALSE);
+}
+
+void DesktopWindow::printScale() {
+ char *newTitle = new char[strlen(desktopName)+20];
+ sprintf(newTitle, "%s @ %i%%", desktopName, getDesktopScale());
+ SetWindowText(handle, TStr(newTitle));
+ delete [] newTitle;
}
void
void setDesktopScale(int scale);
int getDesktopScale() const { return buffer->getScale(); }
void fitBufferToWindow(bool repaint = true);
+ void printScale();
// - Set the cursor to render when the pointer is within the desktop buffer
void setCursor(int w, int h, const Point& hotspot, void* data, void* mask);