⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gs_lev2.ps

📁 GhostScript的源代码
💻 PS
📖 第 1 页 / 共 2 页
字号:
  ifelse
} bind odef
end

% We would like to define exitserver as a procedure, using the code
% that the Red Book says is equivalent to it.  However, since startjob
% resets the exec stack, we can't do this, because control would never
% proceed past the call on startjob if the exitserver is successful.
% Instead, we need to construct exitserver out of pieces of startjob.

serverdict begin

/exitserver {			% <password> exitserver -
  true exch { .startnewjob } .startjob not {
    /exitserver /invalidaccess signalerror
  } if
} bind def

end		% serverdict

% ------ Compatibility ------ %

% In Level 2 mode, the following replace the definitions that gs_statd.ps
% installs in statusdict and serverdict.
% Note that statusdict must be allocated in local VM.
% We don't bother with many of these yet.

/.dict1 { exch mark 3 1 roll .dicttomark } bind def

currentglobal false setglobal 25 dict exch setglobal begin
currentsystemparams

% The following do not depend on the presence of setpagedevice.
/buildtime 1 index /BuildTime get def
/byteorder 1 index /ByteOrder get def
/checkpassword { .checkpassword 0 gt } bind def
dup /DoStartPage known
 { /dostartpage { /DoStartPage getsystemparam } bind def
   /setdostartpage { /DoStartPage .dict1 setsystemparams } bind def
 } if
dup /StartupMode known
 { /dosysstart { /StartupMode getsystemparam 0 ne } bind def
   /setdosysstart { { 1 } { 0 } ifelse /StartupMode .dict1 setsystemparams } bind def
 } if
%****** Setting jobname is supposed to set userparams.JobName, too.
/jobname { /JobName getuserparam } bind def
/jobtimeout { /JobTimeout getuserparam } bind def
/ramsize { /RamSize getsystemparam } bind def
/realformat 1 index /RealFormat get def
dup /PrinterName known
 { /setprintername { /PrinterName .dict1 setsystemparams } bind def
 } if
/printername
 { currentsystemparams /PrinterName .knownget not { () } if exch copy
 } bind def
currentuserparams /WaitTimeout known
 { /waittimeout { /WaitTimeout getuserparam } bind def
 } if

% The following do require setpagedevice.
/.setpagedevice where { pop } { (%END PAGEDEVICE) .skipeof } ifelse
/defaulttimeouts
 { currentsystemparams dup
   /JobTimeout .knownget not { 0 } if
   exch /WaitTimeout .knownget not { 0 } if
   currentpagedevice /ManualFeedTimeout .knownget not { 0 } if
 } bind def
/margins
 { currentpagedevice /Margins .knownget { exch } { [0 0] } ifelse
 } bind def
/pagemargin
 { currentpagedevice /PageOffset .knownget { 0 get } { 0 } ifelse
 } bind def
/pageparams
 { currentpagedevice
   dup /Orientation .knownget { 1 and ORIENT1 { 1 xor } if } { 0 } ifelse exch
   dup /PageSize get aload pop 3 index 0 ne { exch } if 3 2 roll
   /PageOffset .knownget { 0 get } { 0 } ifelse 4 -1 roll
 } bind def
/setdefaulttimeouts
 { exch mark /ManualFeedTimeout 3 -1 roll
   /Policies mark /ManualFeedTimeout 1 .dicttomark
   .dicttomark setpagedevice
   /WaitTimeout exch mark /JobTimeout 5 2 roll .dicttomark setsystemparams
 } bind def
/.setpagesize { 2 array astore /PageSize .dict1 setpagedevice } bind def
/setduplexmode { /Duplex .dict1 setpagedevice } bind def
/setmargins
 { exch 2 array astore /Margins .dict1 setpagedevice
 } bind def
/setpagemargin { 0 2 array astore /PageOffset .dict1 setpagedevice } bind def
/setpageparams
 { mark /PageSize 6 -2 roll
   4 index 1 and ORIENT1 { 1 } { 0 } ifelse ne { exch } if 2 array astore
   /Orientation 5 -1 roll ORIENT1 { 1 xor } if
   /PageOffset counttomark 2 add -1 roll 0 2 array astore
   .dicttomark setpagedevice
 } bind def
/setresolution
 { dup 2 array astore /HWResolution .dict1 setpagedevice
 } bind def
%END PAGEDEVICE

% The following are not implemented yet.
%manualfeed
%manualfeedtimeout
%pagecount
%pagestackorder
%setpagestackorder

pop		% currentsystemparams

% Flag the current dictionary so it will be swapped when we
% change language levels.  (See zmisc2.c for more information.)
/statusdict currentdict def

currentdict end
/statusdict exch .forcedef	% statusdict is local, systemdict is global

% ------ Color spaces ------ %

% Define the setcolorspace procedures:
%	<colorspace> proc <colorspace'|null>
/colorspacedict mark
  /DeviceGray { pop 0 setgray null } bind
  /DeviceRGB { pop 0 0 0 setrgbcolor null } bind
  /setcmykcolor where
   { pop /DeviceCMYK { pop 0 0 0 1 setcmykcolor null } bind
   } if
  /.setcieaspace where
   { pop /CIEBasedA { NOCIE { pop 0 setgray null } { dup 1 get .setcieaspace } ifelse } bind
   } if
  /.setcieabcspace where
   { pop /CIEBasedABC { NOCIE { pop 0 0 0 setrgbcolor null } { dup 1 get .setcieabcspace } ifelse } bind
   } if
  /.setciedefspace where
   { pop /CIEBasedDEF { NOCIE { pop 0 0 0 setrgbcolor null } { dup 1 get .setciedefspace } ifelse } bind
   } if
  /.setciedefgspace where
   { pop /CIEBasedDEFG { NOCIE { pop 0 0 0 1 setcmykcolor null } { dup 1 get .setciedefgspace } ifelse } bind
   } if
  /.setseparationspace where
   { pop /Separation { dup 2 get setcolorspace dup .setseparationspace } bind
   } if
  /.setindexedspace where
   { pop /Indexed { dup 1 get setcolorspace dup .setindexedspace } bind
   } if
  /.nullpatternspace [/Pattern] readonly def
  /.setpatternspace where
   { pop /Pattern
      { dup type /nametype eq { pop //.nullpatternspace } if
	dup length 1 gt { dup 1 get setcolorspace } if
        dup .setpatternspace
      } bind
   } if
  /.setdevicenspace where
   { pop /DeviceN { dup 2 get setcolorspace dup .setdevicenspace } bind
   } if
  /.setdevicepixelspace where
   { pop /DevicePixel { dup .setdevicepixelspace } bind
   } if
  currentdict /.nullpatternspace .undef
.dicttomark def

/.devcs [
  /DeviceGray /DeviceRGB /DeviceCMYK /DevicePixel
] readonly def
/currentcolorspace {		% - currentcolorspace <array>
  .currentcolorspace dup type /integertype eq {
    //.devcs exch 1 getinterval
  } if
} odef
currentdict /.devcs .undef

/setcolorspace {		% <name|array> setcolorspace -
  dup dup dup type /nametype ne { 0 get } if
  //colorspacedict exch get exec
  dup null eq { pop } { .setcolorspace } ifelse pop
} odef

% ------ CIE color rendering ------ %

% Define findcolorrendering and a default ColorRendering ProcSet.

/findcolorrendering {		% <intentname> findcolorrendering
				%   <crdname> <found>
  /ColorRendering /ProcSet findresource
  1 index .namestring (.) concatstrings
  1 index /GetPageDeviceName get exec .namestring (.) concatstrings
  2 index /GetHalftoneName get exec .namestring
  concatstrings concatstrings
  dup /ColorRendering resourcestatus {
    pop pop exch pop exch pop true
  } {
    pop /GetSubstituteCRD get exec false
  } ifelse
} odef

5 dict dup begin

/GetPageDeviceName {		% - GetPageDeviceName <name>
  currentpagedevice dup /PageDeviceName .knownget {
    exch pop
  } {
    pop /none
  } ifelse
} bind def

/GetHalftoneName {		% - GetHalftoneName <name>
  currenthalftone /HalftoneName .knownget not { /none } if
} bind def

/GetSubstituteCRD {		% <intentname> GetSubstituteCRD <crdname>
  pop /DefaultColorRendering
} bind def

end
% The resource machinery hasn't been activated, so just save the ProcSet
% and let .fixresources finish the installation process.
/ColorRendering exch def

% Define setcolorrendering.

/.colorrenderingtypes 5 dict def

/setcolorrendering {		% <crd> setcolorrendering -
  dup /ColorRenderingType get //.colorrenderingtypes exch get exec
} odef

/.setcolorrendering1 where { pop } { (%END CRD) .skipeof } ifelse

.colorrenderingtypes 1 {
  dup .buildcolorrendering1 .setcolorrendering1
} .bind put

% Initialize the default CIE rendering dictionary.
% The most common CIE files seem to assume the "calibrated RGB color space"
% described on p. 189 of the PostScript Language Reference Manual,
% 2nd Edition; we simply invert this transformation back to RGB.
mark
   /ColorRenderingType 1
% We must make RangePQR and RangeLMN large enough so that values computed by
% the assumed encoding MatrixLMN don't get clamped.
   /RangePQR [0 0.9505 0 1 0 1.0890] readonly
   /TransformPQR
     [ {exch pop exch pop exch pop exch pop} bind dup dup ] readonly
   /RangeLMN [0 0.9505 0 1 0 1.0890] readonly
   /MatrixABC
    [ 3.24063 -0.96893  0.05571
     -1.53721  1.87576 -0.20402
     -0.49863  0.04152  1.05700
    ] readonly
   /EncodeABC [ {0 .max 0.45 exp} bind dup dup] readonly
   /WhitePoint [0.9505 1 1.0890] readonly
	% Some Genoa tests seem to require the presence of BlackPoint.
   /BlackPoint [0 0 0] readonly
.dicttomark setcolorrendering

%END CRD

% Initialize a CIEBased color space for sRGB.
/CIEsRGB [ /CIEBasedABC
  mark
    /DecodeLMN [ {
      dup 0.03928 le { 12.92321 div } { 0.055 add 1.055 div 2.4 exp } ifelse
    } bind dup dup ] readonly
    /MatrixLMN [
      0.412457 0.212673 0.019334
      0.357576 0.715152 0.119192
      0.180437 0.072175 0.950301
    ] readonly
    /WhitePoint [0.9505 1.0 1.0890] readonly
  .dicttomark readonly
] readonly def

% ------ Painting ------ %

% A straightforward definition of execform that doesn't actually
% do any caching.
/.execform1 {
	% This is a separate operator so that the stacks will be restored
	% properly if an error occurs.
  dup /Matrix get concat
  dup /BBox get aload pop
  exch 3 index sub exch 2 index sub rectclip
  dup /PaintProc get
  1 index /Implementation known not {
    1 index dup /Implementation null .forceput readonly pop
  } if
  exec
} .bind odef	% must bind .forceput

/.formtypes 5 dict
  dup 1 /.execform1 load put
def

/execform {			% <form> execform -
  gsave {
    dup /FormType get //.formtypes exch get exec
  } stopped grestore { stop } if
} odef

/.patterntypes 5 dict
  dup 1 /.buildpattern1 load put
def

/makepattern {			% <proto_dict> <matrix> makepattern <pattern>
  //.patterntypes 2 index /PatternType get get
  .currentglobal false .setglobal exch
		% Stack: proto matrix global buildproc
  3 index dup length 1 add dict .copydict
  3 index 3 -1 roll exec 3 -1 roll .setglobal
  1 index /Implementation 3 -1 roll put
  readonly exch pop exch pop
} odef

/setpattern {			% [<comp1> ...] <pattern> setpattern -
  currentcolorspace 0 get /Pattern ne {
    [ /Pattern currentcolorspace ] setcolorspace
  } if setcolor
} odef

% Extend image and imagemask to accept dictionaries.
% We must create .imagetypes and .imagemasktypes outside level2dict,
% and leave some extra space because we're still in Level 1 mode.
systemdict begin
/.imagetypes 5 dict
  dup 1 /.image1 load put
def
/.imagemasktypes 5 dict
  dup 1 /.imagemask1 load put
def
end

/.image /image load def
/image {
  dup type /dicttype eq {
    dup /ImageType get //.imagetypes exch get exec
  } {
    //.image
  } ifelse
} odef
currentdict /.image undef

/.imagemask /imagemask load def
/imagemask {
  dup type /dicttype eq {
    dup /ImageType get //.imagemasktypes exch get exec
  } {
    //.imagemask
  } ifelse
} odef
currentdict /.imagemask undef

end				% level2dict

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -