/EDIT
A bit more straightforward

Here’s a little class to get density-independent pixels, and pixels from DIP:

usage…