Autor Tema: 32bits blur  (Leído 2971 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado Grew

  • Full Member
  • ***
  • Mensajes: 123
  • Karma: 3
    • Ver Perfil
32bits blur
« en: Enero 28, 2011, 04:52:25 am »
I juste wanted to share this little code which make a blur effect with 32bits graph mode. (With alpha)

Código: [Seleccionar]
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:

Código: [Seleccionar]
graph=blur32bits(file FPG, origine graph, blur intensity);
It can be improved.

Info: this is a uniform blur (not gauss).
« última modificación: Enero 28, 2011, 05:28:39 am por Grew »
My game developer instagram :
https://www.instagram.com/ben_dev_game/

Conectado SplinterGU

  • Hero Member
  • *****
  • Mensajes: 12414
  • Karma: 366
  • Sexo: Masculino
    • Ver Perfil
Re: 32bits blur
« Respuesta #1 en: Enero 28, 2011, 03:30:58 pm »
what difference have with bennugd blur?
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

Desconectado handsource-dyko

  • Hero Member
  • *****
  • Mensajes: 568
  • Karma: 32
  • Sexo: Masculino
  • I'm the eye in the sky.
    • Ver Perfil
    • dyko designs
Re: 32bits blur
« Respuesta #2 en: Enero 29, 2011, 02:37:16 am »
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. 

Desconectado Grew

  • Full Member
  • ***
  • Mensajes: 123
  • Karma: 3
    • Ver Perfil
Re: 32bits blur
« Respuesta #3 en: Enero 29, 2011, 03:37:19 am »
Cita de: SplinterGU
what difference have with bennugd blur?

The Bennu blur fonction don't support 32bits mode:

Cita de: WikiBennu
Only 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.
My game developer instagram :
https://www.instagram.com/ben_dev_game/

Conectado SplinterGU

  • Hero Member
  • *****
  • Mensajes: 12414
  • Karma: 366
  • Sexo: Masculino
    • Ver Perfil
Re: 32bits blur
« Respuesta #4 en: Enero 29, 2011, 05:50:22 am »
Cita de: SplinterGU
what difference have with bennugd blur?

The Bennu blur fonction don't support 32bits mode:

Cita de: WikiBennu
Only 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.
Download Lastest BennuGD Release: http://www.bennugd.org/node/2