I juste wanted to share this little code which make a blur effect with 32bits graph mode. (With alpha)
function int blur32bits(int file, int graph, int dist)
private
map;
px,py;
dx,dy;
r,g,b,a;
nbDist;
finalA,finalR,finalG,finalB;
begin
if(dist == 0)
return map_clone(file, graph);
end
dx = graphic_info(file, graph, G_WIDTH);
dy = graphic_info(file, graph, G_HEIGHT);
map = map_new(dx, dy, 32);
for(y = 0; y < dy; y++)
for(x = 0; x < dx; x++)
finalR = finalG = finalB = finalA = 0;
nbDist = 0;
for(py = y-dist/2; py < y+dist/2; py++)
for(px = x-dist/2; px < x+dist/2; px++)
if(px =>0 and py=>0 and px<dx and py<dy)
get_rgba(map_get_pixel(file, graph, px, py), &r, &g, &b, &a);
finalR+=r;
finalG+=g;
finalB+=b;
finalA+=a;
nbDist++;
end
end
end
if(nbDist > 0)
map_put_pixel(0 ,map , x, y, rgba(finalR/nbDist, finalG/nbDist ,finalB/nbDist ,finalA/nbDist)) ;
end
end
end
return map;
end
Exemple of how to use:
graph=blur32bits(file FPG, origine graph, blur intensity);
It can be improved.
Info: this is a uniform blur (not gauss).