![有人可以解釋一下 xrandr --scale 是如何運作的嗎?](https://rvso.com/image/231063/%E6%9C%89%E4%BA%BA%E5%8F%AF%E4%BB%A5%E8%A7%A3%E9%87%8B%E4%B8%80%E4%B8%8B%20xrandr%20--scale%20%E6%98%AF%E5%A6%82%E4%BD%95%E9%81%8B%E4%BD%9C%E7%9A%84%E5%97%8E%EF%BC%9F.png)
來自文件:
Changes the dimensions of the output picture. If the y value is
omitted, the x value will be used for both dimensions. Values
larger than 1 lead to a compressed screen (screen dimension big‐
ger than the dimension of the output mode), and values less than
1 lead to a zoom in on the output. This option is actually a
shortcut version of the --transform option.
咱們試試:
當我打字時,--xrandr --output eDP 1.2x1.2
螢幕會變小約 20%(這一點已驗證)
當我打字時,--xrandr --output eDP 0.8x0.8
螢幕變得絕對巨大,放大了 20% 以上(這偽造了文件)
當我打字時,--xrandr --output eDP 1x1
它會變得更大!它正在放大。
當我打字時,--xrandr --output eDP 1.5x1.5
它又變小了。但它仍然大於--scale 1.2x1.2
,相對縮放的進一步證據。
當我打字時--xrandr --output eDP 1.5x1.5
什麼事也沒有發生。等等——這是否意味著這些變換不是相對應用的?
當我打字時,--xrandr --output eDP 2x2
它基本上會回到原來的大小......這不是 2 倍比例! (原始尺寸為 1920x1080,縮放比例為 1 倍)。
--scale
的簡寫也是如此--transform
,其描述為:
--transform a,b,c,d,e,f,g,h,i
Specifies a transformation matrix to apply on the output. A bi‐
linear filter is selected automatically unless the --filter pa‐
rameter is also specified. The mathematical form corresponds
to:
a b c
d e f
g h i
The transformation is based on homogeneous coordinates. The ma‐
trix multiplied by the coordinate vector of a pixel of the out‐
put gives the transformed coordinate vector of a pixel in the
graphic buffer. More precisely, the vector (x y) of the output
pixel is extended to 3 values (x y w), with 1 as the w coordi‐
nate and multiplied against the matrix. The final device coordi‐
nates of the pixel are then calculated with the so-called ho‐
mogenic division by the transformed w coordinate. In other
words, the device coordinates (x' y') of the transformed pixel
are:
x' = (ax + by + c) / w' and
y' = (dx + ey + f) / w' ,
with w' = (gx + hy + i) .
Typically, a and e corresponds to the scaling on the X and Y
axes, c and f corresponds to the translation on those axes, and
g, h, and i are respectively 0, 0 and 1. The matrix can also be
used to express more complex transformations such as keystone
correction, or rotation. For a rotation of an angle T, this
formula can be used:
cos T -sin T 0
sin T cos T 0
0 0 1
As a special argument, instead of passing a matrix, one can pass
the string none, in which case the default values are used (a
unit matrix without filter).
因此,如果我寫“xrandr --output eDP --scale 1.5x1.5”,這將創建一個變換矩陣:
M =
1.5 0 0
0 1.5 0
0 0 1
我使用 * 表示點積,(x,y) 是一些座標
所以這等於:
w' = (0x + 0y + 1) = 1
x' = (1.5x + 0y + 1) / w' = 1.5x
y' = (0x + 1.5y + 1) / w' = 1.5y
這需要從最後一個 x,y 座標進行線性和相對變換!可是等等,如果根據文檔,比例值 > 1 應該壓縮輸出,這似乎實際上是在擴展輸出,因為 (x,y) 被乘以 1.5。
我正在使用兩個顯示器,如果這意味著什麼的話,我什至沒有了解它如何影響另一個顯示器的螢幕空間
答案1
我試圖幫助你 - 昨天我讀了文檔,但很難理解。
我在下面畫了這幅畫。
x'=x cos T + y -sin T + c | a b c
y'=x sin T + y cos T + f | d e f | g=0, h=0, i=1
x 和 y(以顯示器上輸出模式的像素為單位)
x' 和 y'(以圖形緩衝區中螢幕影像的像素為單位)
我有一台顯示器:例如角度 10 度,比例 1.2 -> cos 10 x 1.2 = 1.1818,sin 10 x 1.2 = 0.2084
xrandr --output "DVI-D-0" --transform 1.1818,-0.2084,0,0.2084,1.1818,0,0,0,1
之後呼叫 xrandr 的輸出xrandr
Screen 0: minimum 8 x 8, current 2270 x 1677, maximum 32767 x 32767
DVI-D-0 connected primary 2176x930+0+0 (normal left inverted right x axis y axis) 531mm x 299mm
1920x1080 60.00*+
1680x1050 59.95
1600x1200 60.00
1440x900 59.89
1280x1024 75.02 60.02
1280x960 60.00
1152x864 75.00
1024x768 75.03 70.07 60.00
800x600 75.00 72.19 60.32 56.25
640x480 75.00 72.81 59.94
HDMI-0 disconnected (normal left inverted right x axis y axis)
DP-0 disconnected (normal left inverted right x axis y axis)
DP-1 disconnected (normal left inverted right x axis y axis)
2176x930 必須是圖形緩衝區中的圖像
(2176 x cos 10 + 930 x sin 10) / 1.2 = 1920
但我不確定畫中的螢幕(黃色)!
緩衝區頂部像素中的圖像到顯示器螢幕底部之間的距離為:
2176 x sin 10 + 1080 x 1,2=1674,
但這包括空白顯示器,但如果圖像超出顯示器,我敢打賭這幅畫是正確的。
您可以透過以下方式返回舊設定:
xrandr --output "DVI-D-0" --transform 1,0,0,0,1,0,0,0,1
保存您打開的每個文件,有兩次我崩潰了,我的顯示器沒有信號,因為輸入錯誤,不得不重新啟動!