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

📄 pdf_draw.ps

📁 GhostScript的源代码
💻 PS
📖 第 1 页 / 共 2 页
字号:
%    Copyright (C) 1994, 1995, 1997, 1998 Aladdin Enterprises.  All rights reserved.
% 
% This file is part of Aladdin Ghostscript.
% 
% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
% or distributor accepts any responsibility for the consequences of using it,
% or for whether it serves any particular purpose or works at all, unless he
% or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
% License (the "License") for full details.
% 
% Every copy of Aladdin Ghostscript must include a copy of the License,
% normally in a plain ASCII text file named PUBLIC.  The License grants you
% the right to copy, modify and redistribute Aladdin Ghostscript, but only
% under certain conditions described in the License.  Among other things, the
% License requires that the copyright notice and this notice be preserved on
% all copies.

% $Id: pdf_draw.ps $
% pdf_draw.ps
% PDF drawing operations (graphics, text, and images).

% We don't handle the following PDF 1.0/1.1 elements yet: (identified by
%	style strings, except in a few known fonts
%	font descriptor resources, except for MissingWidth
%	text clipping modes
%		What do these mean??

/.setlanguagelevel where { pop 2 .setlanguagelevel } if
.currentglobal true .setglobal
/pdfdict where { pop } { /pdfdict 100 dict def } ifelse
GS_PDF_ProcSet begin
pdfdict begin

% For simplicity, we use a single interpretation dictionary for all
% PDF graphics operations, even though this is too liberal.
/drawopdict 100 dict def

% ================================ Graphics ================================ %

% ---------------- Functions ---------------- %

/fnrdict mark
  0 { .resolvefn0 }
  2 { }
  3 { .resolvefn3 }
.dicttomark readonly def

/.resolvefn0 {
		% Don't lose our place in PDFfile.
  PDFfile fileposition exch
  dup true resolvestream
		% The stream isn't positionable, so read all the data now.
		% Stack: filepos fndict stream
  1 index /Range oget length 2 idiv 2 index /BitsPerSample oget mul
  2 index /Size oget { mul } forall
  7 add 8 idiv string
  1 index exch readstring pop exch closefile
		% Stack: filepos fndict data
  exch dup length 1 add dict .copydict
  dup /DataSource 4 -1 roll put
  .buildfunction
  exch PDFfile exch setfileposition
} bdef

/.resolvefn3 {
  dup /Functions oget mark exch dup { resolvefunction } forall
  counttomark -1 roll astore cleartomark
} bdef

/resolvefunction {	% <fndict> resolvefunction <function>
  dup /FunctionType oget //fnrdict exch get exec
} bdef

/resolveidfunction {
  dup /Identity eq { pop { } } { resolvefunction } ifelse
} bdef

% ---------------- Halftones ---------------- %

/spotfunctions mark
  /Round {
    abs exch abs 2 copy add 1 le {
      dup mul exch dup mul add 1 exch sub 
    } {
      1 sub dup mul exch 1 sub dup mul add 1 sub
    } ifelse
  }
  /Diamond {
    abs exch abs 2 copy add .75 le {
      dup mul exch dup mul add 1 exch sub
    } {
      2 copy add 1.23 le {
	.85 mul add 1 exch sub
      } {
	1 sub dup mul exch 1 sub dup mul add 1 sub
      } ifelse
    } ifelse
  }
  /Ellipse {
    abs exch abs 2 copy 3 mul exch 4 mul add 3 sub dup 0 lt {
      pop dup mul exch .75 div dup mul add 4 div 1 exch sub
    } {
      dup 1 gt {
	pop 1 exch sub dup mul exch 1 exch sub
	.75 div dup mul add 4 div 1 sub
      } {
	.5 exch sub exch pop exch pop
      } ifelse
    } ifelse
  }
  /EllipseA { dup mul .9 mul exch dup mul add 1 exch sub }
  /InvertedEllipseA { dup mul .9 mul exch dup mul add 1 sub }
  /EllipseB { dup 5 mul 8 div mul exch dup mul exch add sqrt 1 exch sub }
  /EllipseC { dup mul .9 mul exch dup mul add 1 exch sub }
  /InvertedEllipseC { dup mul .9 mul exch dup mul add 1 sub }
  /Line { exch pop abs neg }
  /LineX { pop }
  /LineY { exch pop }
  /Square { abs exch abs 2 copy lt { exch } if pop neg }
  /Cross { abs exch abs 2 copy gt { exch } if pop neg }
  /Rhomboid { abs exch abs 0.9 mul add 2 div }
  /DoubleDot { 2 {360 mul sin 2 div exch } repeat add }
  /InvertedDoubleDot { 2 {360 mul sin 2 div exch } repeat add neg }
  /SimpleDot { dup mul exch dup mul add 1 exch sub }
  /InvertedSimpleDot { dup mul exch dup mul add 1 sub }
  /CosineDot { 180 mul cos exch 180 mul cos add 2 div }
  /Double { exch 2 div exch 2 { 360 mul sin 2 div exch } repeat add }
  /InvertedDouble {
    exch 2 div exch 2 { 360 mul sin 2 div exch } repeat add neg
  }
.dicttomark readonly def

/htrdict mark
  1 { .resolveht1 }
  5 { .resolveht5 }
	% We don't support types 6, 10, or 16 yet.
.dicttomark readonly def

/.resolveht1 {
  mark exch {
    oforce
    1 index /SpotFunction eq {
      dup type /nametype eq
	{ //spotfunctions exch get } { resolvefunction }
      ifelse
    } {
      1 index /TransferFunction eq {
	resolveidfunction
      } if
    } ifelse
  } forall .dicttomark
} bdef

/.resolveht5 {
  mark exch {
    oforce dup type /dicttype eq { resolvehalftone } if
  } forall .dicttomark
} bdef

/resolvehalftone {	% <dict> resolvehalftone <halftone>
  dup /HalftoneType get //htrdict exch get exec
} bdef

% ---------------- Graphics state management ---------------- %

/cmmatrix matrix def
drawopdict begin
			% Graphics state stack
  /q { q } def
  /Q { Q } def
			% Graphics state setting
  /cm { //cmmatrix astore concat } def
  /i /setflat load def
  /J /setlinecap load def
  /d /setdash load def
  /j /setlinejoin load def
  /w /setlinewidth load def
  /M /setmiterlimit load def
  /gs { gs } def
end

/gsparamdict mark
  /Type { pop }
  /SA { setstrokeadjust }
  /OP { setoverprint }
  /BG { resolveidfunction setblackgeneration }
  /UCR { resolveidfunction setundercolorremoval }
  /TR { resolveidfunction settransfer }
  /HT {
    dup /Default eq {
      pop .setdefaultscreen
    } {
	%****** NOT FINISHED ******
      resolvehalftone sethalftone
    } ifelse
  }
  /HTP { aload pop sethalftonephase }
  /SM { setsmoothness }
  /Font { aload pop Tf }
  /LW { setlinewidth }
  /LC { setlinecap }
  /LJ { setlinejoin }
  /ML { setmiterlimit }
  /D { aload pop setdash }
  /FL { setflat }
  /RI { ri }
.dicttomark readonly def
/gs {			% <gsres> gs -
  Page /ExtGState rget {
    { oforce exch gsparamdict exch .knownget { exec } { pop } ifelse }
    forall
  } if
} bdef

% ---------------- Color setting ---------------- %

% The keys here are resolved (PostScript, not PDF) color space names.
/csncompdict mark
  /DeviceGray { pop 1 }
  /DeviceRGB { pop 3 }
  /DeviceCMYK { pop 4 }
  /CIEBasedA { pop 1 }
  /CIEBasedABC { pop 3 }
  /Separation { pop 1 }
  /DeviceN { 2 oget length }
.dicttomark readonly def

% Perhaps some of the values in the following need to be modified
% depending on the WhitePoint value....
/cslabinit mark
  /DecodeABC [{16 add 116 div} bind {500 div} bind {200 div} bind]
  /MatrixABC [1 1 1 1 0 0 0 0 -1]
  /DecodeLMN [
    {dup 6 29 div ge {dup dup mul mul} {4 29 div sub 108 841 div mul} ifelse
     0.9505 mul} bind
    {dup 6 29 div ge {dup dup mul mul} {4 29 div sub 108 841 div mul} ifelse
     } bind
    {dup 6 29 div ge {dup dup mul mul} {4 29 div sub 108 841 div mul} ifelse
     1.0890 mul} bind
  ]
.dicttomark readonly def

/csrdict mark
  /DeviceGray {
    /DefaultGray Page /ColorSpace rget { exch pop resolvecolorspace } if
  }
  /DeviceRGB {
    /DefaultRGB Page /ColorSpace rget { exch pop resolvecolorspace } if
  }
  /DeviceCMYK { }
  /CalGray {
    1 oget dup /Gamma knownoget {
      exch dup length 1 add dict .copydict
      dup /DecodeA 4 -1 roll /exp load 2 packedarray cvx put
    } if
    /CIEBasedA exch 2 array astore
  }
  /CalRGB {
    1 oget dup /Gamma known 1 index /Matrix known or {
      dup length 2 add dict .copydict
      dup /Matrix knownoget { 1 index /MatrixABC 3 -1 roll put } if
      dup /Gamma knownoget {
        [ exch { /exp load 2 packedarray cvx } forall
        ] 1 index /DecodeABC 3 -1 roll put
      } if
    }
    if /CIEBasedABC exch 2 array astore 
  }
  /CalCMYK {
    pop /DeviceCMYK		% not defined by Adobe
  }
  /Lab {
    1 oget dup length 3 add dict .copydict
    dup /Range knownoget not { [-100 100 -100 100] } if
    [-100 0 null null null null] dup 2 4 -1 roll putinterval
    1 index /RangeABC 3 -1 roll put
    //cslabinit exch copy
    /CIEBasedABC exch 2 array astore
  }
  /ICCBased {
		% Since the PostScript interpreter doesn't support these yet,
		% always substitute an alternate space.
    dup /Alternate knownoget {
      exch pop
    } {
      /N get { null /DeviceGray null /DeviceRGB /DeviceCMYK } exch get
    } ifelse resolvecolorspace
  }
  /Separation {
    aload pop exch oforce resolvecolorspace exch oforce resolvefunction
    4 array astore
  }
  /DeviceN {
    aload pop 3 -1 roll oforce
    3 -1 roll oforce resolvecolorspace
    3 -1 roll oforce resolvefunction
    4 array astore
  }
  /Indexed {
    aload pop 3 -1 roll resolvecolorspace 3 1 roll
    oforce dup type /stringtype eq {
      pop
    } {
		% The color lookup table is a stream.
		% Get its contents.  Don't lose our place in PDFfile.
		% Stack: /Indexed basespace hival lookup
	PDFfile fileposition 5 1 roll true resolvestream

⌨️ 快捷键说明

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