image_io_20240725.0.0_e3fcdc57/src/image_io-operations.ads

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
-- Image I/O: output in PPM, BMP, PNG, and QOI formats; input in BMP, GIF, JPG, PNG, PNM, QOI, and TGA formats
-- Copyright (C) by Pragmada Software Engineering
-- Released under the terms of the BSD 3-Clause license; see https://opensource.org/licenses

with Ada.Directories;
with Image_IO.Holders;

package Image_IO.Operations is
   Invalid_File : exception;

   procedure Write_P3 (File_Name : in String; Image : in Image_Data);
   -- Creates a file named File_Name; writes Image to it in P3 format; and closes the file
   -- The file will have Unix (LF) line terminators

   procedure Write_P6 (File_Name : in String; Image : in Image_Data);
   -- Creates a file named File_Name; writes Image to it in P6 format; and closes the file
   -- The file will have Unix (LF) line terminators

   procedure Write_BMP (File_Name : in String; Image : in Image_Data);
   -- Creates a file named Name; writes Image to it in BMP format; and closes the file

   procedure Write_QOI (File_Name : in String; Image : in Image_Data);
   -- Creates a file named Name; writes Image to it in QOI format; and closes the file

   procedure Write_PNG (File_Name : in String; Image : in Image_Data; Grayscale : in Boolean := False);
   -- Creates a file named Name; writes Image to it in PNG format; and closes the file
   -- If Grayscale, treats Image as a grayscale image, with all pixels having equal Red, Green, and Blue components. The Red
   -- component is the only one used for the output
   -- Otherwise, treats Image as a color image

   procedure Read (Name : in String; Image : in out Holders.Handle) with
      Pre => Ada.Directories.Exists (Name) and then Ada.Directories.Kind (Name) in Ada.Directories.Ordinary_File;
end Image_IO.Operations;