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).
what difference have with bennugd blur?
One suggestion, could you perhaps add some comments in the code explaining what each line/block of code does.
That makes it a bit easier to understand.
Quote from: SplinterGUwhat difference have with bennugd blur?
The Bennu blur fonction don't support 32bits mode:
Quote from: WikiBennuOnly 16bit graphics are supported on 16bit video mode.
http://wiki.bennugd.org/index.php?title=Blur
After tries, there is no alpha whith the bennu blur fonction.
Quote from: Grew on January 29, 2011, 11:37:19 AM
Quote from: SplinterGUwhat difference have with bennugd blur?
The Bennu blur fonction don't support 32bits mode:
Quote from: WikiBennuOnly 16bit graphics are supported on 16bit video mode.
http://wiki.bennugd.org/index.php?title=Blur
After tries, there is no alpha whith the bennu blur fonction.
it's must be work with 32bits...
yes, not alpha, but it can be fixed easy.
anyway, thanks for it.