Can I deliberately reduce resolution and add a border around screen using xrandr?

Screen resolution, 3D Acceleration, nVidia, ATI
Forum rules
Before you post please read this
Post Reply
1branchonthevine
Level 1
Level 1
Posts: 5
Joined: Wed Dec 18, 2013 9:18 am

Can I deliberately reduce resolution and add a border around screen using xrandr?

Post by 1branchonthevine » Mon Jan 08, 2018 3:37 pm

The short: i need to reduce the effective resolution of my screen by a few pixels on all sides, so that there is an intentional dead-space (black border) around my screen, where my resolution would go from an effective full 3840 x 2160 (4k resolution), down to something like 3780 x 2100 (-30px from each side), and then have this new lower resolution not just be scaled up to the full size of the screen, but that it instead would just be smaller and wasting the reduced space with a dead border.

The long: i have a dead 42" monitor/tv that has an ir/infrared optic touchscreen, the touch screen is good, but the LCD is broken. I want to replace the LCD parts, but newer 4k monitor/tv's are 43", not 42" anymore. So if i place the new 43" screen behind the 42" touchscreen, it will have hidden data behind the touch frame, and the touch area will be uncalibrated for the viewing area. The preferred way i might get around this would be to reduce the resolution of the 4k monitor, thus adding a border around the screen that matches the viewing area of the smaller touchscreen. The problem is that I've done lots of google searches on xrandr, but all of them lead to getting rid of the boarder around an improperly set up screen, mostly leading down a path of changing zoom settings in the monitor/tv, or mention xrandr scaling/overscalling/underscan/transform, but nothing that i have found seems to deliberately reduce the resolution and add a border like I want it to do... I've looked at xrandr scaling/overscan, and this seems to just stretch the image, and from my impressions, just negatively affecting image quality. Then there is xrandr transform, which just seems to shift the full 4k image by an specified offset off the screen. Any ideas?

Please help, trying to get a cost effective kiosk solution as soon as possible.

1branchonthevine
Level 1
Level 1
Posts: 5
Joined: Wed Dec 18, 2013 9:18 am

Re: Can I deliberately reduce resolution and add a border around screen using xrandr?

Post by 1branchonthevine » Tue Jan 09, 2018 12:19 pm

This is the closest i can get to what i want, but unfortunately scaling is still a problem.
found this formula on a touchscreen calibration form, thought i could use it for xrandr
c0,0,c1,0,c3,c3,0,0,1
c0=Reduced active area Wpx / Total Native Wpx
c2=Reduced active area Hpx / Total Native Hpx
c1=Px offset x axis / T native Wpx
c3=Px offset y axis / T native Hpx

this gave me:
c0=1900/1920=0.989583333
c2=1060/1080=0.981481481
c1=10/1920=0.005208333
c3=10/1080=0.009259259

so:
xrandr --output VGA1 --transform 0.989583333,0,0.981481481,0,0.981481481,0.009259259,0,0,1

This did not work since xrandr uses pixels for c1 and c3 offsets, so:
xrandr --output VGA1 --transform 0.989583333,0,-10,0,0.981481481,-10,0,0,1

Almost works,I get a dead-space border on the left and top, but the right and bottom scales up to the edges of the display, so no border on right and bottom edges, just stretched screen.

Then i noticed after looking at data from xrandr --verbose, that my laptop screen had this property, but my test screen on HDMI1 did not:
xrandr --verbose
Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 32767 x 32767
LVDS1 connected (normal left inverted right x axis y axis)
....
Transform: 1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
....
scaling mode: Full aspect
supported: None, Full, Center, Full aspect

HDMI1 connected primary 1900x1060+0+0 (0x49) normal (normal left inverted right x axis y axis)
...
Transform: 1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
...
aspect ratio: Automatic
supported: Automatic, 4:3, 16:9

even tried the VGA port to see if scaling would work properly (nope):

VGA1 connected primary 1900x1060+0+0 (0x49) normal (normal left inverted right x axis y axis) 521mm x 293mm
...
Transform: 0.989578 0.000000 -10.000000
0.000000 0.981476 -10.000000
0.000000 0.000000 1.000000
...

So i looked up forced "center" scaling mode in xrandr and tried to force scaling to center, but got this error:
xrandr --output VGA1 --set "scaling mode" "Center"
X Error of failed request: BadName (named color or font does not exist)
Major opcode of failed request: 140 (RANDR)
Minor opcode of failed request: 11 (RRQueryOutputProperty)
Serial number of failed request: 36
Current serial number in output stream: 36

-------------------------------------------
Finally found this issue on a separate forum:
The Scaling mode property is not yet implemented in the intel driver (see here). It is implemented in the proprietary AMD and NVIDIA drivers and since recentlty in the open source radeon driver (here).
However you can work around this limitation by performing the scaling manually with xrandr:
Assume your screen has a native resolution of 1920x1080 and you want to display an unstretched 1024x768 resolution. The proportion of the aspect ratios is 16/9 to 4/3. so 1.333333 to 1.

xrandr --output HDMI1 --mode 1024x768 --scale 1.33333333x1 --panning 1024x768

This puts the screen in the right resolution with the right aspect ratio. But it is not centered. To achieve this we need to use the transform option to put it (roughly) in the center of the screen (1024*1.3333333 - 1024 = 342 / 2 = 171):

xrandr --output HDMI1 --mode 1024x768 --panning 1024x768 --transform 1.33333333,0,-171,0,1,0,0,0,1
-------------------------------------------
I have an intel system, so i will be trying an nvidia system shortly. I tried these settings for giggles, and had the same issue with auto full scaling.

Post Reply

Return to “Graphics Cards & Monitors”