Page 1 of 1

Using pixel-perfect half resolution on HiDPI displays

Posted: Mon Feb 10, 2014 6:47 pm
by RexCortex
This tutorial will help you to use half-resolution (ie. 1600x900) on Hi-DPI displays (ie. 3200x1800) without the blurriness induced by hardware/software scaling.

Cinnamon and most other DE have currently poor Hi-DPI support for recent Hi-DPI laptops like the Yoga 2 Pro.
By default, resolutions like 3200x1800 are not suited for DEs, resulting tiny unreadable characters and graphics.

The options are:
  • Scale the theme and fonts
    Change the resolution
    Rescale the screen using xrandr
Theme and fonts scaling doesn't work with software having hardcoded positions for graphics.
Changing resolution to non-native resolution will result in blurriness due to LCD display scaling.

Another option is to use xrandr, which enable buffering screen content in any resolution, and then rescale it to display's resolution.
According to xrandr documentation http://www.x.org/archive/X11R7.5/doc/ma ... ndr.1.html:
--scale xxy
Changes the dimensions of the output picture. Values superior to 1 will lead to a compressed screen (screen dimension bigger than the dimension of the output mode), and values below 1 leads to a zoom in on the output. This option is actually a shortcut version of the --transform option.
Which leads to --transform option documentation
--transform a,b,c,d,e,f,g,h,i
Specifies a transformation matrix to apply on the output. Automatically a bilinear filter is selected.
So If we rescale the screen, screen-content will be rescaled using a bilinear filtering. What we do want is having pixel-perfect quadruple pixels so every pixel dimension is twice its native size without any filtering. Unfortunately, xrandr cannot be forced to disable filtering. Let's modify this behaviour by modifying and recompiling xrandr:
Download here: http://cgit.freedesktop.org/xorg/app/xrandr/ (xrandr-1.X.X.tar.gz) the source code and unzip/untar.
XRandR source content is all located in xrandr.c file
Let's go to line 2821 - 2824 (for xrandr-1.4.1):

Code: Select all

	    if (sx != 1 || sy != 1)
		config_output->transform.filter = "bilinear";
	    else
		config_output->transform.filter = "nearest";
Let's change the behaviour by changing line 2821 to

Code: Select all

if ((sx != 1 || sy != 1) && (sx != 0.5 || sy != 0.5))
(you can also remove lines 2821 to 2823 if you never want to apply bilinear filtering).
Nearest filtering is applying nearest pixel's color to the current pixel, which is the behaviour that we want.

To compile xrandr, you need:

Code: Select all

sudo apt-get install build-essential autoconf xutils-dev
Compile xrandr:

Code: Select all

./autogen.sh
make
Then you can directly use your compiled xrandr:

Code: Select all

./xrandr --output eDP1 --mode "3200x1800" --scale "0.5x0.5"
Now your workspace is a bit pixelated, but crisp (no blurriness at all). For optimal quality, use full hinting on fonts (available through Mint Control center).
Image

I'll maybe update this tutorial with some images and links. Do not hesitate to provide feedback. Sorry for my bad english.

Re: Using pixel-perfect half resolution on HiDPI displays

Posted: Mon Jun 09, 2014 4:07 pm
by matthewp
This is the greatest forum post of all time. You have no idea how many hours I've spent trying to scale themes, font, everything else, and when I change DEs? I have to do it all again. This fixes the issue once and for all. I could kiss you right now.

Re: Using pixel-perfect half resolution on HiDPI displays

Posted: Tue Jun 10, 2014 1:28 pm
by RexCortex
Glad to help you!
They did a great job on HiDPI support with the last Cinnamon but there are still too much applications which are unusable due to hardcoded layout.
In the meantime, I think this solution is a bit more comfortable for the eyes.

Re: Using pixel-perfect half resolution on HiDPI displays

Posted: Fri Aug 01, 2014 8:47 am
by ifq
hi, RexCortex
first of all, thank you for posting this method.

I have trouble while following your method. I already modified & compiled the source.
when I run the cmd:

Code: Select all

./xrandr --output VBOX0 --mode "3200x1800" --scale "0.5x0.5"
my screen turn to all black, but the cursor remains there.

I download xrandr-1.4.2, my environment is: Win8.1 64bit laptop host, linux mint 17 MATE target OS.

could you give me some advices? thank you.

Re: Using pixel-perfect half resolution on HiDPI displays

Posted: Mon Dec 22, 2014 1:44 pm
by l0xde
Although this post is not so recent anymore, the HiDPI problem still exists.

I just registered only to say a Big Thank You to RexCortex!
I have a Dell M3800 and your solution works like a charm!

There is still some way to go for true resolution independent GUIs. Some major DEs have begun to implement this but many applications still look bad (I'm looking at you, Chrome!). Guess, we will have to stick with the lower resolution for some more time.

Thanks again!

Re: Using pixel-perfect half resolution on HiDPI displays

Posted: Wed Aug 12, 2015 5:59 pm
by Ansmann
Download here: http://cgit.freedesktop.org/xorg/app/xrandr/ (xrandr-1.X.X.tar.gz) the source code and unzip/untar.
Sorry. As it seems I'm quite stupid. How can I download a zip or tar.gz from the link you gave?

Re: Using pixel-perfect half resolution on HiDPI displays

Posted: Thu Aug 27, 2015 9:01 am
by DHainzl
First of all, thank you very much for that tutorial! I needed some adaptions to make it work for the current Linux Mint version (Rafaela), but I got it :)

Here's the adapted version; I made it with Linux Mint 17.2 Rafaela, pretty fresh installation, and xrandr 1.4.3:

Prerequisites

Code: Select all

$ sudo apt-get install build-essential autoconf xutils-dev automake dkms gksu libxrandr-dev mesa-utils
(Compiled from this tutorial and the second post in this (German))

Downloading
As Ansmann mentioned, I could also not find the download link for the sources. However, there's the git link on this page (git://anongit.freedesktop.org/xorg/app/xrandr), so we can download it with our Terminal:

Change into the directory where you want the sources to download:

Code: Select all

$ cd ~/Downloads
Clone them into a subfolder "xrandr":

Code: Select all

$ git clone git://anongit.freedesktop.org/xorg/app/xrandr
Change into the downloaded folder

Code: Select all

$ cd xrandr
List available tags (=> versions) of the code

Code: Select all

$ git tag -l
This should give a list of all the available Versions of the code. Choose the most recent version of xrandr-XXX, in my case this is xrandr-1.4.3. Now switch to the tag:

Code: Select all

$ git checkout tags/xrandr-1.4.3
Make the edit
The file is still xrandr.c; the lines in version 1.4.3 are 2886 - 2889. If you have a newer version or are in doubt, search for the block

Code: Select all

if (!strcmp ("--scale", argv[i]))
{
// ...
}
where you should find the applying of the filter.


Building
Run the following commands in your Terminal:

Code: Select all

$ ./autogen.sh
$ make
Use the compiled xrandr
You can use it the same way as RexCortex said. If you need to find out which screen you need to change, run

Code: Select all

$ ./xrandr -q
which prints all available screens with their respective resolutions.

Re: Using pixel-perfect half resolution on HiDPI displays

Posted: Wed Jan 06, 2016 1:52 pm
by overkill22
hi guys,
Thanx for this tutorial.

I'm wondering if it is still useful now.
I need to solve this HiDPI resolution problem on my screen that is 13.3" with 1920x1080 (so cannot apply the 2x setting).
How should I proceed?

Re: Using pixel-perfect half resolution on HiDPI displays

Posted: Tue Apr 05, 2016 10:46 am
by qx0195263
RexCortex wrote:So If we rescale the screen, screen-content will be rescaled using a bilinear filtering. What we do want is having pixel-perfect quadruple pixels so every pixel dimension is twice its native size without any filtering. Unfortunately, xrandr cannot be forced to disable filtering.
With a brand new patch, xrandr can now be forced to disable filtering (i.e. using nearest neighbor), and actually it does it by default now (once the patch is merged) for resolutions like 960x540 @ 1920x1080, 1280x720 @ 2560x1440, 1600x900 @ 3200x1800, 1920x1080 @ 3840x2160 and so on..., see:

https://patchwork.freedesktop.org/patch/79564/

:)

It's a result of those:

https://bugs.freedesktop.org/show_bug.cgi?id=94816
https://bugs.freedesktop.org/show_bug.cgi?id=94820
https://bugs.freedesktop.org/show_bug.cgi?id=94819

:wink:

Re: Using pixel-perfect half resolution on HiDPI displays

Posted: Sat Jul 16, 2016 3:27 pm
by tonklin
qx0195263, any chance to get xrandr with this patch as *.deb for non-programmers?
or maybe a set of files to be copied to certain location?
this is a holy grail for retro-computing on hi-res screens!

Re: Using pixel-perfect half resolution on HiDPI displays

Posted: Fri Jan 27, 2017 6:46 am
by DavidTerp
Great trick ! I followed this guide but I have a compilation error with make, just after this :

Code: Select all

./autogen.sh
make
I have this error :

Code: Select all

make: *** No rule to make target ......
I addded all the dependancy mentionned.
Please, could you help me to compil successfully ?

Re: Using pixel-perfect half resolution on HiDPI displays

Posted: Wed May 02, 2018 10:18 am
by Geeklund
I just wanted to add that I discovered a simpler solution if you're using nvidia GPU:

Code: Select all

nvidia-settings -a CurrentMetaMode="DP-2: 2880x1800 {ViewPortIn=1440x900, ViewPortOut=2880x180
0, ResamplingMethod=Nearest }, HDMI-0: 1920x1080+1440+0"
This gives me crisp upscaling on my macbooks retina screen, while using a non-scaled FHD as second monitor. Adjust for your own resolution and ports.