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,13 +405,37 @@ 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;
if (halo_radius < 1.0)
{
for (x=0; x < width; x++)
{
for (y=0; y < height; y++)
{
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++)
@ -425,6 +449,7 @@ void render_halo(T & pixmap,
}
}
}
}
}
template <typename T>