[cairo] How to blur one of the r, g or b channels into the alpha channel?
leon.woestenberg at gmail.com
Tue Nov 13 00:27:51 PST 2007
Hello both and all,
On Nov 13, 2007 4:06 AM, A. Walton <awalton at gmail.com> wrote:
> Someday hopefully Cairo will get this internally, so you can skip the
> export/import steps, but this is how I've been doing it and it works
> pretty well. Hope that's helpful.
Sure. I think you touched exactly what I need. Thanks.
For this application, the exact filter is not really important, as
long as some feathering
is achieved. I will look into your suggestions though.
My current piece of code (which was Freetype based) used the following
The weight of each pixel depended on the distance to the filter kernel centre.
unsigned int cover_tot = 0;
unsigned int cover_num = 0;
/* q, p are coords into glyph bitmap, x1, y1 are the blur
filter kernel */
for (int x1 = p - hblur; x1 <= p + hblur; x1++)
for (int y1 = q - vblur; y1 <= q + vblur; y1++)
unsigned int weight = 1 + hblur - abs(x1 - p) + 1 + vblur
- abs(y1 - q);
if (x1 < 0 || x1 >= bitmap->width || y1 < 0 || y1 >= bitmap->rows)
cover_tot += 0;
cover_tot += weight * bitmap->buffer[y1 * bitmap->width + x1];
cover_num += weight;
if (cover_num > 0)
/* @todo: check if rounding is correct */
cover = (cover_tot + (cover_num >> 1)) / cover_num;
> On Nov 12, 2007 6:01 PM, Travis Griggs <tgriggs at cincom.com> wrote:
> > On Nov 12, 2007, at 12:37, Leon Woestenberg wrote:
> > > I would like to blur one of the r, g or b channels into the alpha
> > > channel.
> > >
> > I did something like this a little while back and blogged about it
> > with a big ol' wink cast.
More information about the cairo