/usr/share/doc/libgegl-dev/brightness-contrast.c.html is in libgegl-doc 0.3.30-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | <!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML>
<HEAD>
<TITLE>Enscript Output</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#1F00FF" ALINK="#FF0000" VLINK="#9900DD">
<A NAME="top">
<A NAME="file1">
<H1>../operations/common/brightness-contrast.c</H1>
<PRE>
<I><FONT COLOR="#B22222">/* This file is an image processing operation for GEGL
*
* GEGL is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* GEGL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2006 Øyvind Kolås <pippin@gimp.org>
*/</FONT></I>
#<B><FONT COLOR="#5F9EA0">include</FONT></B> <B><FONT COLOR="#BC8F8F">"config.h"</FONT></B>
#<B><FONT COLOR="#5F9EA0">include</FONT></B> <B><FONT COLOR="#BC8F8F"><glib/gi18n-lib.h></FONT></B>
#<B><FONT COLOR="#5F9EA0">ifdef</FONT></B> <FONT COLOR="#B8860B">GEGL_PROPERTIES</FONT>
<I><FONT COLOR="#B22222">/* Here in the top of the file the properties of the operation is declared,
* this causes the declaration of a structure for containing the data.
*
* The first member of each property_ macro becomes a struct member
* in the GeglProperties struct used when processing.
*/</FONT></I>
<B><FONT COLOR="#0000FF">property_double</FONT></B> (contrast, _(<B><FONT COLOR="#BC8F8F">"Contrast"</FONT></B>), 1.0)
description (_(<B><FONT COLOR="#BC8F8F">"Magnitude of contrast scaling >1.0 brighten < 1.0 darken"</FONT></B>))
value_range (-5.0, 5.0)
ui_range (0.0, 2.0)
<B><FONT COLOR="#0000FF">property_double</FONT></B> (brightness, _(<B><FONT COLOR="#BC8F8F">"Brightness"</FONT></B>), 0.0)
description (_(<B><FONT COLOR="#BC8F8F">"Amount to increase brightness"</FONT></B>))
value_range (-3.0, 3.0)
ui_range (-1.0, 1.0)
#<B><FONT COLOR="#5F9EA0">else</FONT></B>
<I><FONT COLOR="#B22222">/* Specify the base class we're building our operation on, the base
* class provides a lot of the legwork so we do not have to. For
* brightness contrast the best base class is the POINT_FILTER base
* class.
*/</FONT></I>
#<B><FONT COLOR="#5F9EA0">define</FONT></B> <FONT COLOR="#B8860B">GEGL_OP_POINT_FILTER</FONT>
<I><FONT COLOR="#B22222">/* The C prefix used for some generated functions
*/</FONT></I>
#<B><FONT COLOR="#5F9EA0">define</FONT></B> <FONT COLOR="#B8860B">GEGL_OP_NAME</FONT> brightness_contrast
<I><FONT COLOR="#B22222">/* We specify the file we're in, this is needed to make the code
* generation for the properties work.
*/</FONT></I>
#<B><FONT COLOR="#5F9EA0">define</FONT></B> <FONT COLOR="#B8860B">GEGL_OP_C_SOURCE</FONT> brightness-contrast.c
<I><FONT COLOR="#B22222">/* Including gegl-op.h creates most of the GObject boiler plate
* needed, creating a GeglOp instance structure a GeglOpClass
* structure for our operation, as well as the needed code to register
* our new gobject with GEGL.
*/</FONT></I>
#<B><FONT COLOR="#5F9EA0">include</FONT></B> <B><FONT COLOR="#BC8F8F">"gegl-op.h"</FONT></B>
<I><FONT COLOR="#B22222">/* prepare() is called on each operation providing data to a node that
* is requested to provide a rendered result. When prepare is called
* all properties are known. For brightness contrast we use this
* opportunity to dictate the formats of the input and output buffers.
*/</FONT></I>
<B><FONT COLOR="#228B22">static</FONT></B> <B><FONT COLOR="#228B22">void</FONT></B> <B><FONT COLOR="#0000FF">prepare</FONT></B> (GeglOperation *operation)
{
gegl_operation_set_format (operation, <B><FONT COLOR="#BC8F8F">"input"</FONT></B>, babl_format (<B><FONT COLOR="#BC8F8F">"RGBA float"</FONT></B>));
gegl_operation_set_format (operation, <B><FONT COLOR="#BC8F8F">"output"</FONT></B>, babl_format (<B><FONT COLOR="#BC8F8F">"RGBA float"</FONT></B>));
}
<I><FONT COLOR="#B22222">/* For GeglOperationPointFilter subclasses, we operate on linear
* buffers with a pixel count.
*/</FONT></I>
<B><FONT COLOR="#228B22">static</FONT></B> gboolean
<B><FONT COLOR="#0000FF">process</FONT></B> (GeglOperation *op,
<B><FONT COLOR="#228B22">void</FONT></B> *in_buf,
<B><FONT COLOR="#228B22">void</FONT></B> *out_buf,
glong n_pixels,
<B><FONT COLOR="#228B22">const</FONT></B> GeglRectangle *roi,
gint level)
{
<I><FONT COLOR="#B22222">/* Retrieve a pointer to GeglProperties structure which contains all the
* chanted properties
*/</FONT></I>
GeglProperties *o = GEGL_PROPERTIES (op);
gfloat * GEGL_ALIGNED in_pixel;
gfloat * GEGL_ALIGNED out_pixel;
gfloat brightness, contrast;
glong i;
in_pixel = in_buf;
out_pixel = out_buf;
brightness = o->brightness;
contrast = o->contrast;
<B><FONT COLOR="#A020F0">for</FONT></B> (i=0; i<n_pixels; i++)
{
out_pixel[0] = (in_pixel[0] - 0.5f) * contrast + brightness + 0.5;
out_pixel[1] = (in_pixel[1] - 0.5f) * contrast + brightness + 0.5;
out_pixel[2] = (in_pixel[2] - 0.5f) * contrast + brightness + 0.5;
out_pixel[3] = in_pixel[3]; <I><FONT COLOR="#B22222">/* copy the alpha */</FONT></I>
in_pixel += 4;
out_pixel += 4;
}
<B><FONT COLOR="#A020F0">return</FONT></B> TRUE;
}
#<B><FONT COLOR="#5F9EA0">include</FONT></B> <B><FONT COLOR="#BC8F8F">"opencl/brightness-contrast.cl.h"</FONT></B>
<I><FONT COLOR="#B22222">/*
* The class init function sets up information needed for this operations class
* (template) in the GObject OO framework.
*/</FONT></I>
<B><FONT COLOR="#228B22">static</FONT></B> <B><FONT COLOR="#228B22">void</FONT></B>
<B><FONT COLOR="#0000FF">gegl_op_class_init</FONT></B> (GeglOpClass *klass)
{
GeglOperationClass *operation_class;
GeglOperationPointFilterClass *point_filter_class;
gchar *composition = <B><FONT COLOR="#BC8F8F">"<?xml version='1.0' encoding='UTF-8'?>"</FONT></B>
<B><FONT COLOR="#BC8F8F">"<gegl>"</FONT></B>
<B><FONT COLOR="#BC8F8F">"<node operation='gegl:brightness-contrast'>"</FONT></B>
<B><FONT COLOR="#BC8F8F">" <params>"</FONT></B>
<B><FONT COLOR="#BC8F8F">" <param name='contrast'>1.8</param>"</FONT></B>
<B><FONT COLOR="#BC8F8F">" <param name='brightness'>0.25</param>"</FONT></B>
<B><FONT COLOR="#BC8F8F">" </params>"</FONT></B>
<B><FONT COLOR="#BC8F8F">"</node>"</FONT></B>
<B><FONT COLOR="#BC8F8F">"<node operation='gegl:load'>"</FONT></B>
<B><FONT COLOR="#BC8F8F">" <params>"</FONT></B>
<B><FONT COLOR="#BC8F8F">" <param name='path'>standard-input.png</param>"</FONT></B>
<B><FONT COLOR="#BC8F8F">" </params>"</FONT></B>
<B><FONT COLOR="#BC8F8F">"</node>"</FONT></B>
<B><FONT COLOR="#BC8F8F">"</gegl>"</FONT></B>;
operation_class = GEGL_OPERATION_CLASS (klass);
point_filter_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
<I><FONT COLOR="#B22222">/* override the prepare methods of the GeglOperation class */</FONT></I>
operation_class->prepare = prepare;
<I><FONT COLOR="#B22222">/* override the process method of the point filter class (the process methods
* of our superclasses deal with the handling on their level of abstraction)
*/</FONT></I>
point_filter_class->process = process;
gegl_operation_class_set_keys (operation_class,
<B><FONT COLOR="#BC8F8F">"name"</FONT></B>, <B><FONT COLOR="#BC8F8F">"gegl:brightness-contrast"</FONT></B>,
<B><FONT COLOR="#BC8F8F">"title"</FONT></B>, _(<B><FONT COLOR="#BC8F8F">"Brightness Contrast"</FONT></B>),
<B><FONT COLOR="#BC8F8F">"categories"</FONT></B>, <B><FONT COLOR="#BC8F8F">"color"</FONT></B>,
<B><FONT COLOR="#BC8F8F">"reference-hash"</FONT></B>, <B><FONT COLOR="#BC8F8F">"a60848d705029cad1cb89e44feb7f56e"</FONT></B>,
<B><FONT COLOR="#BC8F8F">"description"</FONT></B>, _(<B><FONT COLOR="#BC8F8F">"Changes the light level and contrast. This operation operates in linear light, 'contrast' is a scale factor around 50%% gray, and 'brightness' a constant offset to apply after contrast scaling."</FONT></B>),
<B><FONT COLOR="#BC8F8F">"cl-source"</FONT></B> , brightness_contrast_cl_source,
<B><FONT COLOR="#BC8F8F">"reference-composition"</FONT></B>, composition,
NULL);
}
#<B><FONT COLOR="#5F9EA0">endif</FONT></B> <I><FONT COLOR="#B22222">/* closing #ifdef GEGL_PROPERTIES ... else ... */</FONT></I>
</PRE>
<HR>
<ADDRESS>Generated by <A HREF="http://www.iki.fi/~mtr/genscript/">GNU Enscript 1.6.5.90</A>.</ADDRESS>
</BODY>
</HTML>
|