22

I wonder if there is any graphics library that supports RGB subpixel rendering (like ClearType) for general graphics, not just for text. This would allow one to practically triple the horizontal resolution, and put graphics on third-pixel x positions.

While I think this would be very useful, I couldn't find much on the internet about it, except the following:

Is there any library that implements this, or are there efforts to bring something like this to the Cairo library, for example?


Update:

I'm referring specifically to rendering techniques that take into account that current LCD screens use sub-pixels of different colors. To make a white point, you set all sub-pixels to 'on' or 255. A white line would be several subpixels on top of each other:

...RGB...
...RGB...
...RGB...
...RGB...
...RGB...
...111...

(where . is a fully black sub-pixel, and R, G or B are fully-lit red, green, or blue sub-pixels). Because our eyes can't resolve the sub-pixels, they blend together to make a white line. I could however also make a white line from the following:

....GBR..
....GBR..
....GBR..
....GBR..
....GBR..
....111..

Note that it is perfectly sharp, but positioned at x = 1 1/3 pixels. This is not possible with traditional rendering techniques that draw a slightly blurry white line instead. Here for example R=70% lit, r=30% lit. I didn't work out the math, this is just so you get the idea:

...RGBrgb...
...RGBrgb...
...RGBrgb...
...RGBrgb...
...RGBrgb...
...777333...

Another example is a slope, which you can do a) with full pixels, b) antialiased, or c) with subpixel rendering:

a)  RGB......  b)  RGB......  c)  RGB......
    RGB......      RGBrgb...      .GBR.....
    ...RGB...      rgbRGB...      ..BRG....
    ...RGB...      ...RGB...      ...RGB...
    ...RGB...      ...RGBrgb      ....GBR..
    ......RGB      ...rgbRGB      .....BRG.
    ......RGB      ......RGB      ......RGB

Again, note that this is just a crude example to give you the general idea, but you see that a) is jaggy or aliased, b) is blurry, and c) is as sharp as you can get it on a LCD.

Real implementations of this, for font display (ClearType on Windows and the subpixel rendering in FreeType) have a more sophisticated algorithm. They take into account that individual sub-pixels bleed or shine into each other, they preserve the total color intensity or energy. They also take into account that the subpixel spacing is not even (the spacing between R and G, or G and B (in the pixel) may be smaller than between B and R), and finally that some displays have entirely different pixel layouts.

jdm
  • 9,470
  • 12
  • 58
  • 110
  • Cairo supports sub pixel positioning. All coordinates are double precision. See [cairo_line_to](http://www.cairographics.org/manual/cairo-Paths.html#cairo-line-to) for an example – mbonnin Jul 16 '12 at 16:12
  • 2
    I am aware that you can use non-integer coordinates, but I'm referring to RGB subpixel rendering, not just antialiased rendering. RGB subpixel rendering takes into account that each pixel on a LCD screen is composed of a red, green, and blue subpixel. I'll update the question with a bit more detail. – jdm Jul 16 '12 at 16:16
  • ok, understood. actually I didn't know some font engines could do this (I doubt freetype 'splits' pixels into their RGB values, does it ?). Also this would depend the actual configuration of the rgb matrix so could end up doing more harm than good on screens like the [nexus one](http://arstechnica.com/gadgets/2010/03/secrets-of-the-nexus-ones-screen-science-color-and-hacks/) – mbonnin Jul 16 '12 at 16:28
  • Yeah, it's very dependent on the pixel layout. That's why you shouldn't use it for static images on the web, for example. Freetype can indeed do this. On all modern Linux distributions, Freetype is set up to use antialiasing, rgb subpixel rendering, and "slight" hinting. Slight hinting is pretty nice, it forces the fonts to the pixel grid vertically, but allows free placement horizontally since we have subpixels there. The result is pretty crisp, much like ClearType on Windows. – jdm Jul 16 '12 at 16:47
  • And actually, this doesn't "split" the black or white of the font into hard RGB values, in practice it just adds a hint of orange or blue around the characters. – jdm Jul 16 '12 at 16:49

3 Answers3

8

As far as I know no graphic library with subpixel RGB rendering exists.

Here are a few possible reasons why :

  • Microsoft has a few patents on RGB subpixel rendering technology. I don't know if those patents applies only to font rasterization but if not, it is probably a very good reason why other graphic libraries do not use it.
  • Like pointed in the question, subpixel rendering is relying on a hardware implementation. It works well with displays that compose color by placing side by side 3 color cells (for instance an LCD monitor). For all other display types (plasma, projectors, old CRT), it doesn't work.
  • Subpixel rendering adds horizontal resolution only. This limitation is not problem for font rasterization since it is often horizontally that font needs more resolution (see bold and italic characters and kerning). With "custom" graphic it would be weird to have different resolution on each axis.
  • Subpixel rendering doesn't work with rotational display. For instance, mobile device have to use both RGB subpixel rendering and antialiasing.
  • Subpixel rendering works only with the native resolution of a display.
  • It looks like color blind people have problem with subpixel rendering. See this paper for more information.
  • Subpixel rendering works very well with black on white or white on black backgrounds. With other backgounds the "renderer" has to know the background color to adjust the subpixel effect. For this very reason Office 2013 stopped using ClearType.
  • This is more subjective but the difference between subpixel rendering and antialiasing is very subtle. The cons and added complexity of subpixel rendering might not be worth it.

IMHO, the future of better graphics is with higher pixel density like the Apple retina display.

ForguesR
  • 3,558
  • 1
  • 17
  • 39
2

Someone managed to get some interesting results using ImageMagick. The method and results, as well as an interesting discussion, are exposed here: https://www.imagemagick.org/discourse-server/viewtopic.php?t=19120

Interesting subject, indeed. But the point remains: how useful can the technique be, since such process would only benefit unscaled images on a specific type of display?

Bigue Nique
  • 381
  • 2
  • 5
0

It appears to be possible with AGG at antigrain.com by defining your own conversion pipeline to map the output to device pixels. See https://sourceforge.net/p/vector-agg/mailman/search/?q=LCD

martinwguy
  • 948
  • 6
  • 14