-- $Date: 2004/03/04 05:13:21 $
-- $Revision: 1.3 $
-- $Author: jcrocholl $

with Ada.Exceptions; use Ada.Exceptions;

with PNM; use PNM;

package body PBM is

   PBM_Magic : constant String := "P4";

   -- Read a PBM header from a stream.
   procedure Read_Header
     (Stream : in Stream_Access-- Read from this stream.
      Width  : out Positive;     -- Width of image in pixels.
      Height : out Positive)     -- Height of image in pixels.
   is
      Magic : String2;
   begin
      Read_Header(Stream, Magic, Width, Height);
      if Magic /= PBM_Magic then
         Raise_Exception(Expect_P4'Identity,
           "not a PBM file: expected """ & PBM_Magic &
           """ but found """ & Magic & """");
      end if;
   end Read_Header;

   -- Write a PBM header to a stream.
   procedure Write_Header
     (Stream : in Stream_Access-- Write to this stream.
      Width  : in Positive;      -- Width of image in pixels.
      Height : in Positive) is   -- Height of image in pixels.
   begin
      Write_Header(Stream, PBM_Magic, Width, Height);
   end Write_Header;

end PBM;