[OpenJDK 2D-Dev] MaskFill incorrect gamma correction (sRGB != linear RGB)

Laurent Bourgès bourges.laurent at gmail.com
Thu Aug 14 10:00:51 UTC 2014


Here are questions about the java2d pipeline to understand how colors are
handled as pixel values (conversions):
- BufferedImage use by default the sRGB colorspace (non linear) so its
raster data (RGBA) are encoded as int values (sRGB).

What parts of the java2d pipeline handle color blending in linear RGB
(quality issue) ?
AlphaComposite impl (ogl, xr) .... like the SrcOver operator.
Blit ?

The Javadoc explains conversions between premultiplied alpha images... but
nothing about the colorspace of pixels.

Is it supposed to be always sRGB = the java native color space ?

So the complete pipeline should deal with gamma correction at every color
blending stage...

- if I create a BufferedImage with the CS_LINEAR_RGB colorspace (RGBA
values), I expected the image to have better quality but the final PNG
image remains the same.

Conversion into sRGB happened at some stage or the PNG encoder is buggy ?

- Is it possible to implement a custom MaskBlit / MaskFill in java ? Or I
must fix the C implementations dealing with all possible pixel formats
(rgb, rgba, rgb555 ....) in every pipeline (software, opengl, xrender,

- how could I use an alternative colorspace (cie-lch for example) with the
current pipelines to make color blending in this perfect colorspace and
convert the final image back to sRGB ?

Thanks for your feedback,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/2d-dev/attachments/20140814/8672ae10/attachment.html>

More information about the 2d-dev mailing list