aboutsummaryrefslogtreecommitdiffstats
path: root/libglitter_redistribute_energy_double.3
blob: 4aa0897ba68a891d1936e26cec78e2bc2b17238e (plain) (blame)
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
.TH LIBGLITTER_REDISTRIBUTE_ENERGY_* 3 LIBGLITTER
.SH NAME
libglitter_redistribute_energy_* - Slight blur a text to significantly reduce colour fringing
.SH SYNOPSIS
.LP
.nf
#include <libglitter.h>

void libglitter_redistribute_energy_double(double *restrict \fIraster\fP, size_t \fIrowsize\fP,
                                           size_t \fIwidth\fP, size_t \fIheight\fP,
                                           size_t \fIhkernelsize\fP, size_t \fIvkernelsize\fP,
                                           const double *\fIhkernel\fP, const double *\fIvkernel\fP);

void libglitter_redistribute_energy_float(float *restrict \fIraster\fP, size_t \fIrowsize\fP,
                                          size_t \fIwidth\fP, size_t \fIheight\fP,
                                          size_t \fIhkernelsize\fP, size_t \fIvkernelsize\fP,
                                          const float *\fIhkernel\fP, const float *\fIvkernel\fP);
.fi
.PP
Link with
.IR "-lglitter -lm" .
.SH DESCRIPTION
The
.BR libglitter_redistribute_energy_double ()
and
.BR libglitter_redistribute_energy_float ()
functions up to two 1-dimension convolution kernels (one horizontal
and one vertical) to a raster. The goal is to slightly blur
(redistribute energy between adjacent subpixels) the text
which reduces colour fringing.
.PP
The
.I raster
argument shall be the an image of the text rendered at
subpixel-resolution. It will be modified in place. It
shall be a row-major ordered raster where horizontally
adjacent cells are adjacent in memory (the shall not
be any gapes between the cells' memory areas), however
they may be unused memory between each row. The
.I width
parameter specifies how many cells there are, horizontally,
in the image. The
.I rowsize
parameter specifies how many cells a pointer must be offset
with to mow down a row but stay in the same column: it is
.I width
plus the number of unused elements between each row.
The
.I height
parameter specifies how many cells there are, vertically,
in the image.
.PP
The functions apply the horizontal convolution kernel
.I hkernel
and the
vertical convolution kernel
.I vkernel
to the raster. The functions may assume that the sub of
the elements in each kernel is 1. Each kernel shall have
an odd size. The size is specified via the
.I hkernelsize
parameter for
.I hkernel
and the
.I vkernelsize
parameter for
.IR vkernel .
If
.I hkernelsize
is 1,
.I hkernel
will be ignored and may be
.IR NULL .
If
.I vkernelsize
is 1,
.I vkernel
will be ignored and may be
.IR NULL .
The kernels are applied to each cell offset by the half
of the kernelsize (less 1). However, the function shifts
the image by
.I (hkernelsize-1)/2
cells to the left, and also extends the image by this
amount both on the left and on the right, and it also
shifts the image by
.I (vkernelsize-1)/2
cells to upwards, and and also extends the image by
this amount both above and below.
.PP
Because the function is extends the image by
.I (hkernelsize-1)
cells horizontally and by
.I (vkernelsize-1)
cells vertically, the user must provide a raster that
is prepadded with zeroes. This padding shall be
.I (hkernelsize-1)
cells on the left and
.I (vkernelsize-1)
cells on the top; nothing on the right or on the buttom.
But the pointer
.I raster
shall point to the first cell after this padding; after
the function returns however, the new raster starts at
the first cell in the padding. But additionally, the
user must pad each edge of the raster with zeroes so
there is a raster, than can be input to
.BR libglitter_compose_double (3)
and
.BR libglitter_compose_float (3),
first the first cell in the raster is the first cell of
the first pixel and which have all cells for all pixels.
Specifically, the user shall extend the raster further by
.I (widthmul-(hkernelsize-1)/2%widthmul)%widthmul
cells on both the left and on the right, and by
.I (heightmul-(vkernelsize-1)/2%heightmul)%heightmul
cells on both the top and on the bottom, where
.I widthmul
and
.I heightmul
are arguments to the
.BR libglitter_create_render_context (3)
function.
.PP
By default, these functions do not use hardware acceleration,
they run on the CPU. However the
.BR libglitter_enable_acceleration (3)
may be able to enable hardware acceleration for these
functions. It will require at least the following bits in
its first argument to enable hardware acceleration:
.RS
.TP
.I LIBGLITTER_FEATURE_REDISTRIBUTE | LIBGLITTER_FEATURE_DOUBLE_TYPE
for
.BR libglitter_redistribute_energy_double (),
or
.TP
.I LIBGLITTER_FEATURE_REDISTRIBUTE | LIBGLITTER_FEATURE_FLOAT_TYPE
for
.BR libglitter_redistribute_energy_float ().
.RE
.SH APPLICATION USAGE
The value 1 is suggested for
.I hkernelsize
if the monitor uses vertically stacked subpixels,
the value 3 with the
.I hkernel
.I {1/3.,1/3.,1/3.}
is suggested otherwise as a starting point.
Similarly, the value 1 is suggested for
.I vkernelsize
if the monitor uses horizontally stacked subpixels,
the value 3 with the
.I vkernel
.I {1/3.,1/3.,1/3.} 
is suggested otherwise as a starting point. Because of
both monitor differences, and more important, user
differences, experimentation from the user is required
the find the best convolution kernels, however, it is
safe to assumes that the suggestions on the singleton
kernel
.RI ( {1} )
is optional when suggested.
.SH RETURN VALUES
None.
.SH ERRORS
None.
.SH SEE ALSO
.BR libglitter (7),
.BR libglitter_compose_double (3)