Re: [Gimp-developer] Overlay Mode - fix.



On Tue, Nov 13, 2012 at 9:14 PM, Paul Geraskin <paul_geraskin mail ru> wrote:
> I had some experience in converting sRGB to linear RGB. When I coded in
> GLSL. I have taken this code from blender GLSL shader.
> The main idea is: convert all inputs to linear RGB, then make formula
> calculation, then convert output to sRGB.
>
> The methods from blender GLSL shader (it works per channel):

in GIMP and GEGL code pixel format conversion between well defined
standard color models and pixel formats is the responsibility of
babl, http://gegl.org/babl/

Converting from 8bits per component sRGB to 32 bit floating point with
the same RGB primaries as sRGB but with a linear gamma ramp is done
like this:

babl_process (babl_format ("R'G'B'A u8"), babl_format ("RGBA float"),
source_buffer, destination_buffer, n_pixels);

Other predefined babl_formats of interest could be
"RaGaBaA half" which is 16bit floats in linear light with
premultiplied alpha. Or "Y' u8" which is 8bit grayscale like you'd
find in a grayscale JPG or PNG.

You can extend babls vocabulary of data types and pixel formats at
runtime as well as register optimized fast-paths, that can be combined
for pairs of formats without their own fast paths (possible
conversions are precision and performance profiled at runtime).

/Øyvind K.
-- 
@hodefoting


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