with Allegro.Bitmaps; use Allegro.Bitmaps;
with Allegro.Files; use Allegro.Files;
with Allegro.Palettes; use Allegro.Palettes;
with Allegro_Ids; use Allegro_Ids;
with System; use System;
package LoadPNG is
-- Returns the copyright tag for LoadPNG.
function LoadPNG_Copyright return String;
-- Returns a string describing the library version in the form
-- "LibraryName dotted.version"
function LoadPNG_Version return String;
pragma Postcondition( LoadPNG_Version'Result'Length > 0 );
-- png_screen_gamma is slightly overloaded (sorry):
--
-- A value of 0.0 means: Don't do any gamma correction in load_png()
-- and load_memory_png(). This meaning was introduced in v1.4.
--
-- A value of -1.0 means: Use the value from the environment variable
-- SCREEN_GAMMA (if available), otherwise fallback to a value of 2.2
-- (a good guess for PC monitors, and the value for sRGB colourspace).
-- This is the default.
--
-- Otherwise, the value of png_screen_gamma is taken as-is.
procedure Set_PNG_Screen_Gamma( gamma : Long_Float );
-- Choose zlib compression level for saving file.
-- Default is Z_BEST_COMPRESSION.
procedure Set_PNG_Compression_Level( level : Integer );
-- Load a PNG from disk.
function Load_PNG( filename : String; pal : A_RGB ) return A_Bitmap;
pragma Precondition( filename'Length > 0 );
-- Load a PNG from some place.
function Load_PNG_Pf( fp : not null A_Packfile; pal : A_RGB ) return A_Bitmap;
-- Load a PNG from memory.
function Load_Memory_PNG( buffer : Address;
buffer_size : Natural;
pal : A_RGB ) return A_Bitmap;
-- Save a bitmap to disk in PNG format. Returns 0 on success.
function Save_PNG( filename : String; bmp : A_Bitmap; pal : A_RGB ) return Integer;
pragma Precondition( filename'Length > 0 );
-- Adds `PNG' to Allegro's internal file type table.
-- You can then just use load_bitmap and save_bitmap as usual.
procedure Register_PNG_File_Type;
-- Register an datafile type ID with Allegro, so that when an object
-- with that type ID is encountered while loading a datafile, that
-- object will be loaded as a PNG file.
procedure Register_PNG_Datafile_Object( id : AL_ID );
-- This is supposed to resemble jpgalleg_init in JPGalleg 2.0, just in
-- case you are lazier than lazy. It contains these 3 lines of code:
-- register_png_datafile_object(DAT_ID('P','N','G',' '));
-- register_png_file_type();
-- return 0;
function LoadPNG_Init return Integer;
private
pragma Import( C, Load_PNG_Pf, "load_png_pf" );
pragma Import( C, Load_Memory_PNG, "load_memory_png" );
pragma Import( C, Register_PNG_File_Type, "register_png_file_type" );
pragma Import( C, Register_PNG_Datafile_Object, "register_png_datafile_object" );
pragma Import( C, LoadPNG_Init, "loadpng_init" );
end LoadPNG;