[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
On-screen (low-resolution) image quality
From: |
Arnout Engelen |
Subject: |
On-screen (low-resolution) image quality |
Date: |
Sat, 14 Feb 2009 14:37:32 +0100 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
Hi,
I'm writing a piece of software that (among other things) displays sheet music
(fragments). I've been looking at existing components to take care of rendering
the music, and even though lilypond focuses on print rather than on-screen
viewing, it seems like a powerful option.
I've long been using lilypond for printed sheets (great product! thanks!), but
now started noticing the sheets look rather inconsistent on-screen. This is
particularly clear when looking at stems and staff lines: some are thin/clear,
some are thicker/blurred.
Looking to the archives the typical response when this issue is brought up is
'it looks good on paper, probably something in your pdf viewer, don't worry
about it'. I'd like to explore how to make the on-screen output look good :).
The slim/thick lines are, of course, caused by aliasing done by the ps viewer:
after scaling it turns out there should be a line at 'pixel 16' (causing a neat
clear line at pixel 16) but also one at 'pixel 25,4', causing a blurred line
over pixels 25 and 26).
For on-screen purposes, it'd be nice to produce output that is 'snapped' to a
whole-pixel grid. In case of postscript output, however, this is not possible,
as we cannot predict the scaling factor: ps viewers my decide on a scaling
factor by looking at things like the current screen resolution and physical
size, it doesn't seem elegant to have lilypond take such parameters in
account.
So I decided to look at the PNG output. Turns out for png output, lilypond
first generates intermediate ps code, then uses gs to turn this into png.
Example PNG output at:
http://arnout.engelen.eu/files/dev/linuxmusicians/lilypond/postprocessing/test.png
Notice how the staff lines of the first staff are clearer than the staff
lines of the second staff, and how the stems of the first 2 notes are thicker
than the ones of the second 2 notes.
Luckily, gs in this case doesn't depend on things like screen size, but
specifies a fixed resolution of '101', which (by experimentation, as I
couldn't find any specifications) appears to mean '101 pixels per 72
postscript points'.
This suggests PNG output could be made more consistent by snapping locations
to a coarse whole-pixel grid. To test this, I wrote a simple perl script which
takes the intermediate .ps file and modifies each 'moveto' to move to points
which are a whole number of pixels apart.
http://arnout.engelen.eu/files/dev/linuxmusicians/lilypond/postprocessing/postproc.pl
Output shows the lines are now indeed much more consistent, however of course
new 'off-by-a-pixel' problems are introduced. Example PNG output at:
http://arnout.engelen.eu/files/dev/linuxmusicians/lilypond/postprocessing/processed.png
Do you have any ideas for improving low-resolution output? My script is of
course just a proof of concept - what would be the 'right' way and place to
tackle this?
Kind regards,
Arnout