summaryrefslogtreecommitdiff
path: root/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2021-02-24 14:52:36 +0100
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2021-02-24 14:52:47 +0100
commitbef46b5cb82464713a117b9bdb920735d1b7de37 (patch)
treee645da2fdd342a8a8a41c90b54b2e96e29d849a0 /src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx
parent9f84fd05e8090c3b7554c965d15ac5c41a0d4852 (diff)
Improve precision of GUI scaling for Windows platform.
Diffstat (limited to 'src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx')
-rw-r--r--src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx
index dd9ed5dbc..09dd6fa45 100644
--- a/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx
+++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx
@@ -260,15 +260,14 @@ HRGN Fl_GDI_Graphics_Driver::scale_region(HRGN r, float f, Fl_GDI_Graphics_Drive
pt.y = int(pt.y * (f - 1));
}
RECT *rects = (RECT*)&(pdata->Buffer);
- int delta = (f > 1.75 ? 1 : 0) - int(f/2);
for (DWORD i = 0; i < pdata->rdh.nCount; i++) {
- int x = int(rects[i].left * f) + pt.x;
- int y = int(rects[i].top * f) + pt.y;
+ int x = Fl_GDI_Graphics_Driver::floor(rects[i].left, f) + pt.x;
+ int y = Fl_GDI_Graphics_Driver::floor(rects[i].top, f) + pt.y;
RECT R2;
- R2.left = x + delta;
- R2.top = y + delta;
- R2.right = int(rects[i].right * f) + pt.x - x + R2.left;
- R2.bottom = int(rects[i].bottom * f) + pt.y - y + R2.top;
+ R2.left = x;
+ R2.top = y;
+ R2.right = Fl_GDI_Graphics_Driver::floor(rects[i].right, f) + pt.x - x + R2.left;
+ R2.bottom = Fl_GDI_Graphics_Driver::floor(rects[i].bottom, f) + pt.y - y + R2.top;
rects[i] = R2;
}
r = ExtCreateRegion(NULL, size, pdata);
@@ -287,3 +286,11 @@ Fl_Region Fl_GDI_Graphics_Driver::scale_clip(float f) {
void Fl_GDI_Graphics_Driver::set_current_() {
restore_clip();
}
+
+void Fl_GDI_Graphics_Driver::cache_size(Fl_Image *img, int &width, int &height)
+{
+ float s = scale();
+ width = (s == int(s) ? width * int(s) : floor(width+1));
+ height = (s == int(s) ? height * int(s) : floor(height+1));
+ cache_size_finalize(img, width, height);
+}