1. with Allegro.Bitmaps;                   use Allegro.Bitmaps; 
  2.  
  3. package Image_Filters is 
  4.  
  5.     -- Blurs horizontally only, with a kernel size of one. To increase the 
  6.     -- effect, increase the number of passes. Works only on memory bitmaps in 
  7.     -- Truecolor 16/32bpp modes. If the bitmap is not a memory bitmap then the 
  8.     -- blur will be skipped. 
  9.     -- 
  10.     -- Originally by Sik 
  11.     -- Adapted by Oog 
  12.     -- Adapted and optimized by Kevin Wellwood 
  13.     -- 
  14.     -- Retrieved from http://mb.srb2.org/showthread.php?t=17041 on 11/17/2010 
  15.     procedure Fast_Blur( bmp    : not null A_Bitmap; 
  16.                          x1, y1 : Natural; 
  17.                          x2, y2 : Natural; 
  18.                          passes : Positive := 1 ); 
  19.     pragma Precondition( Get_Width( bmp ) >= 2 ); 
  20.     pragma Precondition( Get_Height( bmp ) >= 2 ); 
  21.     pragma Precondition( x2 >= x1 + 1 and then x2 < Get_Width( bmp ) ); 
  22.     pragma Precondition( y2 >= y1 + 1 and then y2 < Get_Height( bmp ) ); 
  23.  
  24.     -- Super Fast Blur v1.1 
  25.     -- by Mario Klingemann <http://incubator.quasimondo.com> 
  26.     -- 
  27.     -- Tip: Increasing the passes of this filter with a small radius will 
  28.     -- approximate a gaussian blur quite well. 
  29.     procedure Klingemann_Fast_Blur( bmp    : not null A_Bitmap; 
  30.                                     radius : Positive; 
  31.                                     passes : Positive ); 
  32.  
  33.     -- Stack Blur v1.0 
  34.     -- 
  35.     -- Author: Mario Klingemann <mario@quasimondo.com> 
  36.     -- http://incubator.quasimondo.com 
  37.     -- created Feburary 29, 2004 
  38.     -- 
  39.     -- This is a compromise between Gaussian Blur and Box blur 
  40.     -- It creates much better looking blurs than Box Blur, but is 
  41.     -- 7x faster than my Gaussian Blur implementation. 
  42.     -- 
  43.     -- I called it Stack Blur because this describes best how this 
  44.     -- filter works internally: it creates a kind of moving stack 
  45.     -- of colors whilst scanning through the image. Thereby it 
  46.     -- just has to add one new block of color to the right side 
  47.     -- of the stack and remove the leftmost color. The remaining 
  48.     -- colors on the topmost layer of the stack are either added on 
  49.     -- or reduced by one, depending on if they are on the right or 
  50.     -- on the left side of the stack. 
  51.     procedure Klingemann_Stack_Blur( bmp    : not null A_Bitmap; 
  52.                                      radius : Positive; 
  53.                                      passes : Positive ); 
  54.  
  55.     -- Fast Gaussian Blur v1.3 
  56.     -- by Mario Klingemann <http://incubator.quasimondo.com> 
  57.     -- 
  58.     -- What you see is an attempt to implement a Gaussian Blur algorithm 
  59.     -- which is exact but fast. I think that this one should be 
  60.     -- relatively fast because it uses a special trick by first 
  61.     -- making a horizontal blur on the original image and afterwards 
  62.     -- making a vertical blur on the pre-processed image. This 
  63.     -- is a mathematical correct thing to do and reduces the 
  64.     -- calculation a lot. 
  65.  
  66. end Image_Filters;