Render fast subpixel halos.

This commit is contained in:
Hermann Kraus 2013-03-30 02:52:20 +01:00
parent dc486e6971
commit 23d599d7e5

View file

@ -405,23 +405,48 @@ void render_halo(T & pixmap,
unsigned rgba,
int x1,
int y1,
int halo_radius,
double halo_radius,
double opacity,
composite_mode_e comp_op)
{
int width = bitmap->width;
int height = bitmap->rows;
int x, y;
for (x=0; x < width; x++)
if (halo_radius < 1.0)
{
for (y=0; y < height; y++)
for (x=0; x < width; x++)
{
int gray = bitmap->buffer[y*bitmap->width+x];
if (gray)
for (y=0; y < height; y++)
{
for (int n=-halo_radius; n <=halo_radius; ++n)
for (int m=-halo_radius; m <= halo_radius; ++m)
pixmap.composite_pixel(comp_op, x+x1+m, y+y1+n, rgba, gray, opacity);
int gray = bitmap->buffer[y*bitmap->width+x];
if (gray)
{
pixmap.composite_pixel(comp_op, x+x1-1, y+y1-1, rgba, gray*halo_radius*halo_radius, opacity);
pixmap.composite_pixel(comp_op, x+x1, y+y1-1, rgba, gray*halo_radius, opacity);
pixmap.composite_pixel(comp_op, x+x1+1, y+y1-1, rgba, gray*halo_radius*halo_radius, opacity);
pixmap.composite_pixel(comp_op, x+x1-1, y+y1, rgba, gray*halo_radius, opacity);
pixmap.composite_pixel(comp_op, x+x1, y+y1, rgba, gray, opacity);
pixmap.composite_pixel(comp_op, x+x1+1, y+y1, rgba, gray*halo_radius, opacity);
pixmap.composite_pixel(comp_op, x+x1-1, y+y1+1, rgba, gray*halo_radius*halo_radius, opacity);
pixmap.composite_pixel(comp_op, x+x1, y+y1+1, rgba, gray*halo_radius, opacity);
pixmap.composite_pixel(comp_op, x+x1+1, y+y1+1, rgba, gray*halo_radius*halo_radius, opacity);
}
}
}
} else {
for (x=0; x < width; x++)
{
for (y=0; y < height; y++)
{
int gray = bitmap->buffer[y*bitmap->width+x];
if (gray)
{
for (int n=-halo_radius; n <=halo_radius; ++n)
for (int m=-halo_radius; m <= halo_radius; ++m)
pixmap.composite_pixel(comp_op, x+x1+m, y+y1+n, rgba, gray, opacity);
}
}
}
}