Using pixel-perfect half resolution on HiDPI displays

Write tutorials here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Please don't add support questions to tutorials,start your own thread in the appropriate sub-forum instead. Before you post please read this
RexCortex
Level 1
Level 1
Posts: 2
Joined: Mon Feb 10, 2014 5:16 pm

Using pixel-perfect half resolution on HiDPI displays

Postby RexCortex » Mon Feb 10, 2014 6:47 pm

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/man/man1/xrandr.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.

matthewp
Level 1
Level 1
Posts: 1
Joined: Mon Jun 09, 2014 4:05 pm

Re: Using pixel-perfect half resolution on HiDPI displays

Postby matthewp » Mon Jun 09, 2014 4:07 pm

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.

RexCortex
Level 1
Level 1
Posts: 2
Joined: Mon Feb 10, 2014 5:16 pm

Re: Using pixel-perfect half resolution on HiDPI displays

Postby RexCortex » Tue Jun 10, 2014 1:28 pm

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.

ifq
Level 1
Level 1
Posts: 1
Joined: Wed Jun 18, 2014 10:13 pm

Re: Using pixel-perfect half resolution on HiDPI displays

Postby ifq » Fri Aug 01, 2014 8:47 am

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.

l0xde
Level 1
Level 1
Posts: 1
Joined: Mon Dec 22, 2014 1:37 pm

Re: Using pixel-perfect half resolution on HiDPI displays

Postby l0xde » Mon Dec 22, 2014 1:44 pm

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!

Ansmann
Level 1
Level 1
Posts: 4
Joined: Wed Nov 05, 2014 10:59 am

Re: Using pixel-perfect half resolution on HiDPI displays

Postby Ansmann » Wed Aug 12, 2015 5:59 pm

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?

DHainzl
Level 1
Level 1
Posts: 1
Joined: Thu Aug 27, 2015 8:42 am

Re: Using pixel-perfect half resolution on HiDPI displays

Postby DHainzl » Thu Aug 27, 2015 9:01 am

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.

overkill22
Level 4
Level 4
Posts: 204
Joined: Fri Jan 16, 2015 6:09 am
Contact:

Re: Using pixel-perfect half resolution on HiDPI displays

Postby overkill22 » Wed Jan 06, 2016 1:52 pm

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?

qx0195263
Level 1
Level 1
Posts: 8
Joined: Fri May 30, 2014 1:33 pm

Re: Using pixel-perfect half resolution on HiDPI displays

Postby qx0195263 » Tue Apr 05, 2016 10:46 am

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:

tonklin
Level 1
Level 1
Posts: 1
Joined: Sat Jul 16, 2016 2:13 pm

Re: Using pixel-perfect half resolution on HiDPI displays

Postby tonklin » Sat Jul 16, 2016 3:27 pm

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!

DavidTerp
Level 2
Level 2
Posts: 82
Joined: Tue May 17, 2016 11:18 am

Re: Using pixel-perfect half resolution on HiDPI displays

Postby DavidTerp » Fri Jan 27, 2017 6:46 am

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 ?
Mint 17.3 Mate x64 - Intel i5 - Dual boot Windows 7 for gaming only


Return to “Tutorials”

Who is online

Users browsing this forum: Baidu [Spider] and 2 guests