1. with Allegro.Bitmaps;                   use Allegro.Bitmaps; 
  2. with Allegro.Files;                     use Allegro.Files; 
  3. with Allegro.Palettes;                  use Allegro.Palettes; 
  4. with Allegro_Ids;                       use Allegro_Ids; 
  5. with System;                            use System; 
  6.  
  7. package LoadPNG is 
  8.  
  9.     -- Returns the copyright tag for LoadPNG. 
  10.     function LoadPNG_Copyright return String; 
  11.  
  12.     -- Returns a string describing the library version in the form 
  13.     -- "LibraryName dotted.version" 
  14.     function LoadPNG_Version return String; 
  15.     pragma Postcondition( LoadPNG_Version'Result'Length > 0 ); 
  16.  
  17.     -- png_screen_gamma is slightly overloaded (sorry): 
  18.     -- 
  19.     -- A value of 0.0 means: Don't do any gamma correction in load_png() 
  20.     -- and load_memory_png().  This meaning was introduced in v1.4. 
  21.     -- 
  22.     -- A value of -1.0 means: Use the value from the environment variable 
  23.     -- SCREEN_GAMMA (if available), otherwise fallback to a value of 2.2 
  24.     -- (a good guess for PC monitors, and the value for sRGB colourspace). 
  25.     -- This is the default. 
  26.     -- 
  27.     -- Otherwise, the value of png_screen_gamma is taken as-is. 
  28.     procedure Set_PNG_Screen_Gamma( gamma : Long_Float ); 
  29.  
  30.     -- Choose zlib compression level for saving file. 
  31.     -- Default is Z_BEST_COMPRESSION. 
  32.     procedure Set_PNG_Compression_Level( level : Integer ); 
  33.  
  34.     -- Load a PNG from disk. 
  35.     function Load_PNG( filename : String; pal : A_RGB ) return A_Bitmap; 
  36.     pragma Precondition( filename'Length > 0 ); 
  37.  
  38.     -- Load a PNG from some place. 
  39.     function Load_PNG_Pf( fp : not null A_Packfile; pal : A_RGB ) return A_Bitmap; 
  40.  
  41.     -- Load a PNG from memory. 
  42.     function Load_Memory_PNG( buffer      : Address; 
  43.                               buffer_size : Natural; 
  44.                               pal         : A_RGB ) return A_Bitmap; 
  45.  
  46.     -- Save a bitmap to disk in PNG format. Returns 0 on success. 
  47.     function Save_PNG( filename : String; bmp : A_Bitmap; pal : A_RGB ) return Integer; 
  48.     pragma Precondition( filename'Length > 0 ); 
  49.  
  50.     -- Adds `PNG' to Allegro's internal file type table. 
  51.     -- You can then just use load_bitmap and save_bitmap as usual. 
  52.     procedure Register_PNG_File_Type; 
  53.  
  54.     -- Register an datafile type ID with Allegro, so that when an object 
  55.     -- with that type ID is encountered while loading a datafile, that 
  56.     -- object will be loaded as a PNG file. 
  57.     procedure Register_PNG_Datafile_Object( id : AL_ID ); 
  58.  
  59.     -- This is supposed to resemble jpgalleg_init in JPGalleg 2.0, just in 
  60.     -- case you are lazier than lazy.  It contains these 3 lines of code: 
  61.     --   register_png_datafile_object(DAT_ID('P','N','G',' ')); 
  62.     --   register_png_file_type(); 
  63.     --   return 0; 
  64.     function LoadPNG_Init return Integer; 
  65.  
  66. private 
  67.  
  68.     pragma Import( C, Load_PNG_Pf, "load_png_pf" ); 
  69.     pragma Import( C, Load_Memory_PNG, "load_memory_png" ); 
  70.     pragma Import( C, Register_PNG_File_Type, "register_png_file_type" ); 
  71.     pragma Import( C, Register_PNG_Datafile_Object, "register_png_datafile_object" ); 
  72.     pragma Import( C, LoadPNG_Init, "loadpng_init" ); 
  73.  
  74. end LoadPNG;