{ Written by Jacob Sparre Andersen, 1995.02.28. }
{ Changed by Jacob Sparre Andersen, 1995.04.19, 1996.11.11. }

{ Copyright Jacob Sparre Andersen & Tofta Teld, 1995, 1996. }

{$D+,R+,I+,G+,N+,T+,V+,X-,Y+,F+,A+,S+,P+,Q+,B-,L+}

{$IfDef Optimize} {$R-,S-,I-,Q-,D-,L-} {$EndIf}

program ShowBMP;

   uses
     JSSystem, Graph, JSAGraph, Bitmaps, ErrorCodes, Parameters,
     FileUtilities, FileNames, GraphTypes;

   procedure Show_Bitmap (File_Name : string);

   var Bitmap   : PWinBMPFile;
       Boundary : TIntFrame;
       X, Y     : LongInt;

   begin {Show_Bitmap}
      File_Name := DefaultExtension (File_Name, 'BMP');
      if Exists (File_Name) then begin
         New (Bitmap, Init (File_Name));

         with Bitmap^ do begin
            GetBoundary (Boundary);

            StartGraph (Default);
            SetColor (White);
            Bar (0, 0,
                 Boundary.x2 - Boundary.x1 + 2, Boundary.y2 - Boundary.y1 + 2);

            for Y := Boundary.y1 to Boundary.y2 do begin
               for X := Boundary.x1 to Boundary.x2 do begin
                  PutPixel (X-Boundary.x1+1, Y-Boundary.y1+1, GetP(X, Y));
               end {for X};
            end {for Y};
            EndGraph (Default);
         end {with Bitmap^};

         Dispose (Bitmap, Done);
      end else begin
         Error (FileNotFound,
                'ShowBMP couldn''t find the BMP file ' + File_Name + '.');
      end {if};
   end {Show_Bitmap};

begin {ShowBMP}
   CopyrightNotice ('Program ShowBMP, Copyright Jacob Sparre Andersen & ' +
                      'Tofta Teld, 1995.',
                    True);

   if (ParamCount = 0) then begin
      Error (WrongNumberOfParameters,
             'ShowBMP expects to get the name of a BMP file passed as a '+
               'parameter.');
   end else begin
      while (ParamCount > 0) do begin
         Show_Bitmap (ParamStr (1));
         RemoveParameter (1);
      end {while};
   end {if};
end {ShowBMP}.
