Merge branch 'QHD'

This commit is contained in:
Mirek Fidler 2026-04-17 14:58:06 +02:00
commit f24ac4055c
9 changed files with 76 additions and 64 deletions

View file

@ -262,9 +262,6 @@ Image MinifyCached(const Image& img, int nx, int ny, bool co = false);
Image DownSample3x(const Image& src, bool co = false); Image DownSample3x(const Image& src, bool co = false);
Image DownSample2x(const Image& src, bool co = false); Image DownSample2x(const Image& src, bool co = false);
Image DPISmartRescale(const Image& src, Size sz);
Image DPISmartRescaleCached(const Image& src, Size sz);
Image Upscale2x(const Image& src); Image Upscale2x(const Image& src);
Image Downscale2x(const Image& src); Image Downscale2x(const Image& src);
Image Downscale6x(const Image& src); Image Downscale6x(const Image& src);
@ -290,16 +287,17 @@ inline double DPI(double a) { return GetDPIScaleRatio() * a; }
inline Size DPI(int cx, int cy) { return Size(DPI(cx), DPI(cy)); } inline Size DPI(int cx, int cy) { return Size(DPI(cx), DPI(cy)); }
inline Size DPI(Size sz) { return DPI(sz.cx, sz.cy); } inline Size DPI(Size sz) { return DPI(sz.cx, sz.cy); }
Image DPISmartRescale(const Image& src, Size sz);
Image DPISmartRescaleCached(const Image& src, Size sz);
int ImlFlagsToDPIScale(int imlflags); int ImlFlagsToDPIScale(int imlflags);
int DPIScaleToImlFlags(int dpiscale); int DPIScaleToImlFlags(int dpiscale);
inline int DPI2(int dpi200val, int dpi100val) { inline int DPI2(int dpi200val, int dpi100val) {
int scale = GetDPIScale(); int scale = GetDPIScale();
return (dpi200val - dpi100val) * (scale - DPI_100) / 2 + dpi100val; return (dpi200val - dpi100val) * (scale - DPI_100) / 2 + dpi100val;
} }
struct RGBAV { struct RGBAV {
dword r, g, b, a; dword r, g, b, a;

View file

@ -10,25 +10,42 @@ topic "GUI Scaling";
[b42;2 $$9,9#13035079074754324216151401829390:normal] [b42;2 $$9,9#13035079074754324216151401829390:normal]
[2 $$0,0#00000000000000000000000000000000:Default] [2 $$0,0#00000000000000000000000000000000:Default]
[{_} [{_}
[ {{10000@(113.42.0) [s0;%% [*@7;4 GUI Scaling]]}}&] [ {{10000@(113.42.0) [s0;%% [*@7;4 Image Pixel DPI Scaling]]}}&]
[s0;i448;a25;kKO9;@(0.0.255) &] [s0;i448;a25;kKO9;@(0.0.255) &]
[ {{10000F(128)G(128)@1 [s0;%% [* Function List]]}}&] [ {{10000F(128)G(128)@1 [s0;%% [* Function List]]}}&]
[s0;%% &] [s0;%% &]
[s5;:Upp`:`:SetDPIScale`(int`): [@(0.0.255) void] [* SetDPIScale]([@(0.0.255) int]
[*@3 scale])&]
[s2;%% Sets the current image (and image related) [%-*@3 scale]. Can
be one of DPI`_100 (FHD), DPI`_150 (QHD), &]
[s2;%% -|DPI`_200 (UHD), DPI`_300.&]
[s3; &] [s3; &]
[s4; &] [s4; &]
[s5;:Upp`:`:DPI`(const Upp`:`:Image`&`): [_^Upp`:`:Image^ Image]_[* DPI]([@(0.0.255) const]_ [s5;:Upp`:`:SyncDPIScale`(`): [@(0.0.255) void] [* SyncDPIScale]()&]
[_^Upp`:`:Image^ Image][@(0.0.255) `&]_[*@3 img])&] [s2;%% Changes the scaling based on GetStdFontCy(). Gets called automatically
[s2;%% Eventually upscales or downscales [%-*@3 img] based on its UHD at the start of U`+`+ application (in CtrlLib). Unless your application
flag and current mode. Standard images are upscaled 2x in UHD is not using CtrlCore, you should not call this one.&]
mode, UHD images are downscaled 2x in standard mode.&] [s3; &]
[s3;%% &] [s4; &]
[s5;:Upp`:`:GetDPIScale`(`): [@(0.0.255) int] [* GetDPIScale]()&]
[s2;%% Returns current scaling .&]
[s3; &]
[s4; &]
[s5;:Upp`:`:GetDPIScaleRatio`(`): [@(0.0.255) double] [* GetDPIScaleRatio]()&]
[s2;%% Returns current scaling as number (E.g. DPI`_150 `-> 1.5).&]
[s3; &]
[s4; &]
[s5;:Upp`:`:GetDPIUnScaleRatio`(`): [@(0.0.255) double] [* GetDPIUnScaleRatio]()&]
[s2;%% Returns 1 / GetDPIScaleRatio().&]
[s3; &]
[s4; &] [s4; &]
[s5;:Upp`:`:DPI`(int`): [@(0.0.255) int]_[* DPI]([@(0.0.255) int]_[*@3 a])&] [s5;:Upp`:`:DPI`(int`): [@(0.0.255) int]_[* DPI]([@(0.0.255) int]_[*@3 a])&]
[s2;%% Returns 2 `* [%-*@3 a] if UHD is active and [%-*@3 a] otherwise.&] [s5;:Upp`:`:DPI`(double`): [@(0.0.255) double] [* DPI]([@(0.0.255) double]
[s3;%% &] [*@3 a])&]
[s4; &] [s5;:Upp`:`:DPI`(int`,int`): [_^Upp`:`:Size^ Size]_[* DPI]([@(0.0.255) int]
cx, [@(0.0.255) int] cy)&]
[s5;:Upp`:`:DPI`(Upp`:`:Size`): [_^Upp`:`:Size^ Size]_[* DPI]([_^Upp`:`:Size^ Size]_[*@3 sz]) [s5;:Upp`:`:DPI`(Upp`:`:Size`): [_^Upp`:`:Size^ Size]_[* DPI]([_^Upp`:`:Size^ Size]_[*@3 sz])
&] &]
[s2;%% Returns 2 `* [%-*@3 sz] if UHD is active and [%-*@3 sz] otherwise.&] [s2;%% Scales argument(s) based on current scaling cooeficient (e.g.
[s3;%% &] 2x for DPI`_200, 1.5x for DPI`_150).&]
[s0;%% ]] [s0;%% ]]

View file

@ -1,6 +0,0 @@
TITLE("GUI Scaling")
COMPRESSED
120,156,141,82,239,79,219,48,16,253,87,44,21,80,139,186,234,238,108,199,78,242,165,31,24,63,180,73,155,134,248,20,5,106,90,211,69,107,83,150,164,99,3,193,223,190,115,72,71,209,96,172,138,98,247,238,222,243,123,207,201,10,165,108,234,72,167,223,62,124,138,83,18,59,59,56,132,158,52,40,173,150,168,40,226,23,74,36,77,82,161,165,88,89,41,45,36,211,133,171,235,60,91,144,181,45,136,134,212,35,163,9,141,178,202,162,52,150,24,75,0,4,134,52,42,105,73,39,51,95,79,243,12,120,92,242,25,113,36,99,64,0,131,8,146,12,72,173,16,37,49,5,25,66,208,137,47,103,121,118,28,165,1,160,24,0,58,2,128,136,217,148,2,102,15,48,37,81,2,73,141,177,142,146,75,63,47,202,60,251,219,146,126,211,146,129,164,104,252,178,115,228,84,186,63,214,41,50,52,26,70,61,195,199,42,205,135,197,193,145,100,24,81,164,99,212,138,37,41,160,164,242,223,215,69,229,151,190,108,58,134,2,145,48,189,68,147,178,132,135,135,135,17,42,120,76,
202,176,22,4,214,77,200,53,246,97,80,199,16,107,139,22,164,81,164,13,91,191,118,149,91,118,78,46,21,165,157,15,59,180,189,8,35,78,20,44,235,215,49,19,0,155,224,149,131,212,252,72,155,52,29,56,224,2,40,30,198,61,14,73,106,48,49,24,101,180,98,39,132,17,114,144,16,252,243,53,36,229,170,90,186,69,158,5,0,132,172,223,248,37,7,254,202,173,23,108,247,238,226,94,100,226,238,14,67,121,220,231,43,28,41,26,193,64,100,53,164,187,187,34,219,31,155,84,137,163,179,19,113,58,117,139,162,156,231,249,253,253,94,30,218,207,111,106,220,135,17,140,216,214,64,112,123,67,121,216,71,178,131,163,246,61,198,39,86,113,184,46,167,77,177,42,197,199,162,110,158,56,185,25,54,50,109,23,245,184,232,52,57,187,190,158,36,147,228,224,243,201,164,63,93,149,117,35,186,202,201,210,205,253,100,111,50,72,68,118,113,190,93,60,23,237,146,95,240,105,140,203,251,217,150,196,150,131,91,47,67,182,39,39,123,129,97,44,69,177,156,231,131,32,135,130,
202,247,63,248,115,89,187,197,226,151,88,95,215,28,141,175,197,170,18,179,213,77,217,253,203,118,223,109,96,226,210,213,126,38,216,109,209,212,226,236,248,64,92,45,220,92,184,114,38,166,235,170,98,38,177,92,205,252,72,156,54,92,115,213,140,81,172,163,22,174,242,27,250,153,160,159,162,40,91,116,24,30,182,187,173,185,63,71,111,38,235,13,89,203,253,24,107,151,239,203,193,22,101,211,230,184,229,158,75,47,7,216,53,216,160,219,74,229,139,111,214,85,89,11,18,147,253,77,0,46,23,197,213,163,88,22,202,151,254,195,183,206,159,218,171,230,171,175,110,138,250,191,68,118,251,211,226,214,63,191,244,80,57,23,225,189,165,248,149,46,159,91,223,190,161,155,7,254,41,60,244,95,81,222,126,199,121,254,27,86,89,138,21,

View file

@ -317,5 +317,16 @@ CKWISE. Flip mode values are compatible with Raster`::GetOrientation
and are equal to EXIF orientation `- 1. This function is intended and are equal to EXIF orientation `- 1. This function is intended
to flip Image to correct orientation (usually JPEG from digital to flip Image to correct orientation (usually JPEG from digital
camera).&] camera).&]
[s2;%% &] [s3; &]
[s4; &]
[s5;:Upp`:`:DPISmartRescale`(const Image`&`,Size`): Image [* DPISmartRescale]([@(0.0.255) c
onst] Image[@(0.0.255) `&] [*@3 src], Size [*@3 sz])&]
[s2;%% Intended to rescale `"not fitting`" icons to current GUI scaling,
using variety of `"smart`" methods (xBR upscaling, Lancosz 3,
bilienear downscaling) to maintain the acceptable appearance.&]
[s3; &]
[s4; &]
[s5;:Upp`:`:DPISmartRescaleCached`(const Image`&`,Size`): Image [* DPISmartRescaleCache
d]([@(0.0.255) const] Image[@(0.0.255) `&] [*@3 src], Size [*@3 sz])&]
[s2;%% Same as DPISmartRescale, with added caching of results.&]
[s0;%% ]] [s0;%% ]]

View file

@ -1,4 +0,0 @@
TOPIC("DPI_en-us")
#include "DPI_en-us.tppi"
END_TOPIC

File diff suppressed because one or more lines are too long

View file

@ -1 +0,0 @@
PREMULTIPLIED

View file

@ -2,9 +2,7 @@ uses
CtrlLib; CtrlLib;
file file
a.iml,
test.iml, test.iml,
Ctrl.iml,
main.cpp; main.cpp;
mainconfig mainconfig

View file

@ -1 +0,0 @@
PREMULTIPLIED