Render fast subpixel halos.
This commit is contained in:
parent
dc486e6971
commit
23d599d7e5
1 changed files with 33 additions and 8 deletions
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue