/imgview.pas
program ImgView;
uses Apricot, GfxManager, CBI, Util, Strings;

var img: ChunkedBitmapImage;
    i, cc: Integer;
    xpos, ypos: Byte;
    p1, p2: PChar;
    arg: String;

begin
    if ParamCount < 1 then begin
        Writeln('Specify one or more files');
        Halt(1);
    end;

    Writeln('Loading... press any key to proceed/exit.');
    for i := 1 to ParamCount do begin
        xpos := 0;
        ypos := 0;
        arg := ParamStr(i);
        p1:= StrScan(@arg[1], '+');
        if p1 <> nil then begin
            arg[0] := Char(p1 - @arg[1]);
            Inc(p1);
            p2 := StrScan(p1, ',');
            if p2 <> nil then begin
                p2^ := Char(0);
                Val(p1, xpos, cc);
                if cc <> 0 then
                    Die('invalid Y coordinate');
                Inc(p2);
                Val(p2, ypos, cc);
                if cc <> 0 then
                    Die('invalid Y coordinate');
            end
            else
                Die('coordinates must be +X,Y');
        end;

        LoadCBI(arg, img);
        if i = 1 then
            ScreenMode(ScreenModeGfx);
        DisplayCBI(img, xpos, ypos);
        ReadKey;
    end;
    ScreenMode(ScreenModeText);
end.