1. -- 
  2. -- Copyright (c) 2012 Kevin Wellwood 
  3. -- All rights reserved. 
  4. -- 
  5. -- This source code is distributed under the Modified BSD License. For terms and 
  6. -- conditions, see license.txt. 
  7. -- 
  8.  
  9. with Allegro.Bitmaps;                   use Allegro.Bitmaps; 
  10.  
  11. -- Note: The Scaling package is not thread-safe. 
  12. package Scaling is 
  13.  
  14.     type Filter_Type is 
  15.     ( 
  16.         Filter_Nearest,    -- effectively no filter 
  17.         Filter_Auto,       -- choose best looking filter 
  18.         Filter_HQX, 
  19.         Filter_2xSaI, 
  20.         Filter_Eagle, 
  21.         Filter_ScaleX 
  22.     ); 
  23.  
  24.     INIT_EXCEPTION : exception; 
  25.  
  26.     ---------------------------------------------------------------------------- 
  27.  
  28.     -- Initializes the scaling filters. This must be called before Scale. 
  29.     -- Raises INIT_EXCEPTION with a message, if not successful. 
  30.     procedure Initialize( color_depth : Integer ); 
  31.  
  32.     -- Finalizes the scaling filters before application exit. Calling this will 
  33.     -- have no effect if Initialize hasn't been called. 
  34.     procedure Finalize; 
  35.  
  36.     -- Scales the upper left corner of the source bitmap onto the upper left 
  37.     -- corner of the destination bitmap. The filter type is used to do the 
  38.     -- scale if it is available for the given magnification. If the requested 
  39.     -- filter can't scale to the requested magnification, the default filter 
  40.     -- is used. Scale will have no effect if Initialize hasn't been called. 
  41.     procedure Scale( src, 
  42.                      dst           : not null A_Bitmap; 
  43.                      src_width, 
  44.                      src_height    : Positive; 
  45.                      magnification : Float; 
  46.                      filter        : Filter_Type := Filter_Nearest ); 
  47.  
  48.     -- Filter names are Filter_Type members without the Filter_ prefix. If the 
  49.     -- name doesn't match a filter, 'default' will be returned. 
  50.     function To_Filter( name    : String; 
  51.                         default : Filter_Type := Filter_Type'First 
  52.                       ) return Filter_Type; 
  53.  
  54.     -- Returns the name of the Filter_Type member. It's name is everything that 
  55.     -- follows after "Filter_". This is the opposite of To_Filter(). 
  56.     function To_Name( filter : Filter_Type ) return String; 
  57.  
  58. end Scaling;