freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ft] Straight FT_PIXEL_MODE_RGBA


From: Alexei Podtelezhnikov
Subject: [ft] Straight FT_PIXEL_MODE_RGBA
Date: Mon, 20 Aug 2018 12:13:13 -0400

Hi all,

I propose to default to straight RGBA color space in FreeType. This is
especially important before the next FreeType release 2.10 with
CPAL/COLR support. I will quote from PNG documentation for the
overarching reason:

"PNG also uses only unassociated alpha, wherein the actual gray or
color values are stored unchanged and are only affected by the alpha
channel at display time. The alternative is associated or
premultiplied alpha, in which the pixel values are effectively
precomposited against a black background; although this allows
slightly faster software compositing, it amounts to a lossy
transformation of the image data and was therefore rejected in the
design of PNG."

For example, the loss of precision in premultiplied data prevents
blending with gamma correction.

The only reason why FreeType has not made this choice yet is
uncompressed CBDT data, which comes premultiplied. Correct me if I am
wrong in all other instances in PNG-compressed CBDT and in CPAL the
bitmap data are straight.

So as a first step in this direction. the attached patch introduces
straight FT_PIXEL_MODE_RGBA and removes premultiplication from
PNG-encoded CBDT data, thus faithfully transmitting the data to the
user.

The second step is to default tt_face_colr_blend_layer and
FT_Bitmap_Blend to FT_PIXEL_MODE_RGBA, with the least data loss. The
third step is to implement gamma corrected blending.

Please comment with your support or objection.

Alexei

Attachment: RGBA.patch
Description: Source code patch


reply via email to

[Prev in Thread] Current Thread [Next in Thread]