晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。   林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。   见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝)   既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。   南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。 sh-3ll

HOME


sh-3ll 1.0
DIR:/proc/thread-self/root/proc/thread-self/root/usr/share/ghostscript/lib/
Upload File :
Current File : //proc/thread-self/root/proc/thread-self/root/usr/share/ghostscript/lib/ps2epsi.ps
% Copyright (C) 2001-2021 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
% implied.
%
% This software is distributed under license and may not be copied,
% modified or distributed except as expressly authorized under the terms
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
% Artifex Software, Inc.,  1305 Grant Avenue - Suite 200, Novato,
% CA 94945, U.S.A., +1(415)492-9861, for further information.

% Convert a PostScript file to an EPSI file, adding the Preview Image.

% If the file is already EPSF, then skip the creation of an EPSF, and
% only add the preview.  A warning is issued if the %%Pages: comment
% indicates that there is more than a single page in the input file.

% Expected invocation:
%   gs -q -dNOOUTERSAVE -dNODISPLAY -dLastPage=1 -sOutputFile=out.epsi --permit-file-read=in.ps -- ps2epsi.ps in.ps

% Usually this will be invoked by the ps2epsi script (or .bat or .cmd versions)

false	% no errors from initial param check
% NOOUTERSAVE is needed for the SAVE to not remove the tempfile (if one was needed)
vmstatus pop pop 0 gt { (Error: missing -dNOOUTERSAVE option) = pop true } if
% NODISPLAY may not be strictly needed, but we don't want to open the default device
/NODISPLAY where { pop } { (Error: missing -dNODISPLAY option) = pop true } ifelse
% LastPage is needed if we are using eps2write on a PostScript (or PDF) file that has multiple pages.
/LastPage where { pop } { (Error: missing -dLastPage option) = pop true } ifelse
% OutputFile is needed so that it gets on the permit-file-writing list
/OutputFile where { pop } { (Error: missing -sOutputFile option) = pop true } ifelse

.shellarguments not count 3 lt or count -1 roll or
{
  (usage:  gs -q -dNOOUTERSAVE -dNODISPLAY -dLastPage=1 -sOutputFile=out.epsi --permit-file-read=in.eps -- ps2epsi.ps in.ps) =
  quit
} {
  dup /InputFile exch def
  (r) file /I exch def
} ifelse

/O OutputFile (w) file def

/S 65535 string def

/R { I S readline not { (Error: Unexpected end of file.) = quit } if } bind def
/WL { O exch writestring O (\n) writestring } bind def	% Write with linefeed
/TName null def

/EPSFheader (%!PS-Adobe-3.0 EPSF-3.0) def
% Read the header to check if this file was EPSF
R
dup EPSFheader ne {
  % InputFile was not EPSF
  pop		% discard the first line of the InputFile
  % run the file through eps2write (into a tempfile) to make an EPSF
  (_ps2epsi) (w+) .tempfile closefile /TName exch def
  /SAVE save def
  (eps2write) finddevice mark /OutputFile TName 3 index putdeviceprops pop
  setdevice
  InputFile run
  SAVE restore
  /I TName (r) file def
  R
} if
WL	% Write the first line (either from InputFile or the tempfile

% From the "5002 Encapsulated PostScript File Format Specification Version 3.0 1 May 1992"
%   The preview section must appear after the header comment section, but
%   before the document prologue definitions. That is, it should immediately
%   follow the %%EndComments: line in the EPS file.
{	% loop until we see the %%EndComments line, writing those lines to output
  R
  dup (%%EndComments) anchorsearch exch pop {	% discard the match or extra copy of the string
    pop exit	% found it
  } if
  % Check the %%Pages: comment to issue a warning if there is more than one page.
  dup (%%Pages:) anchorsearch exch pop {	% discard the match or extra copy of the string
    cvi 1 gt {
      (Warning: EPSI files can only have 1 page, Only the first page will be in the preview.) =
    } if
  } if
  % Collect the BoundingBox data that will be used when generating the preview
  dup (%%BoundingBox:) anchorsearch exch pop {	% discard the match or extra copy of the string
    mark
    exch token not { (Error: invalid BoundingBox parameters) = quit } if
    exch token not { (Error: invalid BoundingBox parameters) = quit } if
    exch token not { (Error: invalid BoundingBox parameters) = quit } if
    exch token not { (Error: invalid BoundingBox parameters) = quit } if
    exch pop ]
    /BBox exch def
    % Preview dimensions
    /PWidth BBox dup 2 get exch 0 get sub def
    /PHeight BBox dup 3 get exch 1 get sub def
  } if
  WL	% send to output file with linefeed.
} loop

WL	% send to output file with linefeed.

% If the InputFile already has a preview, skip past it
R
dup (%%BeginPreview) anchorsearch exch pop {	% discard the match or extra copy of the string
  pop
  % Read lines until after the %%EndPreview
  {
    R
    (%%EndPreview) anchorsearch exch pop {	% discard the match or extra copy of the string
      pop pop exit	% found it
    } if
  } loop
  % Get the next line for use after the generated preview
  R
} 
if
/LineAfterEndComments exch def

//null (w+) .tempfile
closefile			% will be opened by bit device
/Pname exch def

(bit) selectdevice
<<
  /GrayValues 256		% Gray, not monochrome
  /OutputFile Pname
  /TextAlphaBits 4
  /GraphicsAlphaBits 4
  /LastPage 1			% TBD: does this work?
  /.IgnoreNumCopies true
  /Install { BBox 0 get neg BBox 1 get neg translate { 1.0 exch sub } settransfer }	% EPSI 00 is white
  /HWResolution [ 72. 72. ]
  /PageSize [ PWidth PHeight ]
>> setpagedevice

InputFile run

/P Pname (r) file def		% Preview data file
/SP PWidth string def		% One string per image line

% Write the preview
O (%%BeginPreview: ) writestring
O PWidth write==only O ( ) writestring
O PHeight write==only O ( 8 ) writestring
O PHeight PWidth 39 add 40 idiv mul write==	% 40 bytes per line
O flushfile
0 1 PHeight 1 sub {
  pop
  P SP readstring pop
  0 40 PWidth {
    O (% ) writestring		% 82 bytes on each line, plus EOL
    SP exch 40 PWidth 2 index sub .min getinterval   
    O exch writehexstring
    O (\n) writestring
  } for
  pop
} for
(%%EndPreview) WL

% Write the line that followed the %%EndComments
LineAfterEndComments WL

% Copy the remainder of the inputfile
{
  I S readstring exch O exch writestring not { exit } if
} loop

% If we created a tempfile, delete it
TName null ne { TName deletefile } if

quit