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

📄 psoutputdev.cc

📁 这是一个做pdf阅读器的源代码文件,是大家学习阅读器资料的很好参考
💻 CC
📖 第 1 页 / 共 5 页
字号:
  "/pdfIm1 {",  "  /pdfImBuf1 4 index string def",  "  { currentfile pdfImBuf1 readhexstring pop } image",  "} def",  "~1s",  "/pdfIm1Sep {",  "  /pdfImBuf1 4 index string def",  "  /pdfImBuf2 4 index string def",  "  /pdfImBuf3 4 index string def",  "  /pdfImBuf4 4 index string def",  "  { currentfile pdfImBuf1 readhexstring pop }",  "  { currentfile pdfImBuf2 readhexstring pop }",  "  { currentfile pdfImBuf3 readhexstring pop }",  "  { currentfile pdfImBuf4 readhexstring pop }",  "  true 4 colorimage",  "} def",  "~1ns",  "/pdfImM1 {",  "  fCol /pdfImBuf1 4 index 7 add 8 idiv string def",  "  { currentfile pdfImBuf1 readhexstring pop } imagemask",  "} def",  "/pdfImM1a {",  "  { 2 copy get exch 1 add exch } imagemask",  "  pop pop",  "} def",  "~23sn",  "% Level 2 image operators",  "/pdfImBuf 100 string def",  "/pdfIm {",  "  image",  "  { currentfile pdfImBuf readline",  "    not { pop exit } if",  "    (%-EOD-) eq { exit } if } loop",  "} def",  "~23s",  "/pdfImSep {",  "  findcmykcustomcolor exch",  "  dup /Width get /pdfImBuf1 exch string def",  "  dup /Decode get aload pop 1 index sub /pdfImDecodeRange exch def",  "  /pdfImDecodeLow exch def",  "  begin Width Height BitsPerComponent ImageMatrix DataSource end",  "  /pdfImData exch def",  "  { pdfImData pdfImBuf1 readstring pop",  "    0 1 2 index length 1 sub {",  "      1 index exch 2 copy get",  "      pdfImDecodeRange mul 255 div pdfImDecodeLow add round cvi",  "      255 exch sub put",  "    } for }",  "  6 5 roll customcolorimage",  "  { currentfile pdfImBuf readline",  "    not { pop exit } if",  "    (%-EOD-) eq { exit } if } loop",  "} def",  "~23sn",  "/pdfImM {",  "  fCol imagemask",  "  { currentfile pdfImBuf readline",  "    not { pop exit } if",  "    (%-EOD-) eq { exit } if } loop",  "} def",  "/pr { 2 index 2 index 3 2 roll putinterval 4 add } def",  "/pdfImClip {",  "  gsave",  "  0 2 4 index length 1 sub {",  "    dup 4 index exch 2 copy",  "    get 5 index div put",  "    1 add 3 index exch 2 copy",  "    get 3 index div put",  "  } for",  "  pop pop rectclip",  "} def",  "/pdfImClipEnd { grestore } def",  "~23sn",  "% shading operators",  "/colordelta {",  "  false 0 1 3 index length 1 sub {",  "    dup 4 index exch get 3 index 3 2 roll get sub abs 0.004 gt {",  "      pop true",  "    } if",  "  } for",  "  exch pop exch pop",  "} def",  "/funcCol { func n array astore } def",  "/funcSH {",  "  dup 0 eq {",  "    true",  "  } {",  "    dup 6 eq {",  "      false",  "    } {",  "      4 index 4 index funcCol dup",  "      6 index 4 index funcCol dup",  "      3 1 roll colordelta 3 1 roll",  "      5 index 5 index funcCol dup",  "      3 1 roll colordelta 3 1 roll",  "      6 index 8 index funcCol dup",  "      3 1 roll colordelta 3 1 roll",  "      colordelta or or or",  "    } ifelse",  "  } ifelse",  "  {",  "    1 add",  "    4 index 3 index add 0.5 mul exch 4 index 3 index add 0.5 mul exch",  "    6 index 6 index 4 index 4 index 4 index funcSH",  "    2 index 6 index 6 index 4 index 4 index funcSH",  "    6 index 2 index 4 index 6 index 4 index funcSH",  "    5 3 roll 3 2 roll funcSH pop pop",  "  } {",  "    pop 3 index 2 index add 0.5 mul 3 index  2 index add 0.5 mul",  "~23n",  "    funcCol sc",  "~23s",  "    funcCol aload pop k",  "~23sn",  "    dup 4 index exch mat transform m",  "    3 index 3 index mat transform l",  "    1 index 3 index mat transform l",  "    mat transform l pop pop h f*",  "  } ifelse",  "} def",  "/axialCol {",  "  dup 0 lt {",  "    pop t0",  "  } {",  "    dup 1 gt {",  "      pop t1",  "    } {",  "      dt mul t0 add",  "    } ifelse",  "  } ifelse",  "  func n array astore",  "} def",  "/axialSH {",  "  dup 0 eq {",  "    true",  "  } {",  "    dup 8 eq {",  "      false",  "    } {",  "      2 index axialCol 2 index axialCol colordelta",  "    } ifelse",  "  } ifelse",  "  {",  "    1 add 3 1 roll 2 copy add 0.5 mul",  "    dup 4 3 roll exch 4 index axialSH",  "    exch 3 2 roll axialSH",  "  } {",  "    pop 2 copy add 0.5 mul",  "~23n",  "    axialCol sc",  "~23s",  "    axialCol aload pop k",  "~23sn",  "    exch dup dx mul x0 add exch dy mul y0 add",  "    3 2 roll dup dx mul x0 add exch dy mul y0 add",  "    dx abs dy abs ge {",  "      2 copy yMin sub dy mul dx div add yMin m",  "      yMax sub dy mul dx div add yMax l",  "      2 copy yMax sub dy mul dx div add yMax l",  "      yMin sub dy mul dx div add yMin l",  "      h f*",  "    } {",  "      exch 2 copy xMin sub dx mul dy div add xMin exch m",  "      xMax sub dx mul dy div add xMax exch l",  "      exch 2 copy xMax sub dx mul dy div add xMax exch l",  "      xMin sub dx mul dy div add xMin exch l",  "      h f*",  "    } ifelse",  "  } ifelse",  "} def",  "/radialCol {",  "  dup t0 lt {",  "    pop t0",  "  } {",  "    dup t1 gt {",  "      pop t1",  "    } if",  "  } ifelse",  "  func n array astore",  "} def",  "/radialSH {",  "  dup 0 eq {",  "    true",  "  } {",  "    dup 8 eq {",  "      false",  "    } {",  "      2 index dt mul t0 add radialCol",  "      2 index dt mul t0 add radialCol colordelta",  "    } ifelse",  "  } ifelse",  "  {",  "    1 add 3 1 roll 2 copy add 0.5 mul",  "    dup 4 3 roll exch 4 index radialSH",  "    exch 3 2 roll radialSH",  "  } {",  "    pop 2 copy add 0.5 mul dt mul t0 add",  "~23n",  "    radialCol sc",  "~23s",  "    radialCol aload pop k",  "~23sn",  "    encl {",  "      exch dup dx mul x0 add exch dup dy mul y0 add exch dr mul r0 add",  "      0 360 arc h",  "      dup dx mul x0 add exch dup dy mul y0 add exch dr mul r0 add",  "      360 0 arcn h f",  "    } {",  "      2 copy",  "      dup dx mul x0 add exch dup dy mul y0 add exch dr mul r0 add",  "      a1 a2 arcn",  "      dup dx mul x0 add exch dup dy mul y0 add exch dr mul r0 add",  "      a2 a1 arcn h",  "      dup dx mul x0 add exch dup dy mul y0 add exch dr mul r0 add",  "      a1 a2 arc",  "      dup dx mul x0 add exch dup dy mul y0 add exch dr mul r0 add",  "      a2 a1 arc h f",  "    } ifelse",  "  } ifelse",  "} def",  "~123sn",  "end",  NULL};static char *cmapProlog[] = {  "/CIDInit /ProcSet findresource begin",  "10 dict begin",  "  begincmap",  "  /CMapType 1 def",  "  /CMapName /Identity-H def",  "  /CIDSystemInfo 3 dict dup begin",  "    /Registry (Adobe) def",  "    /Ordering (Identity) def",  "    /Supplement 0 def",  "  end def",  "  1 begincodespacerange",  "    <0000> <ffff>",  "  endcodespacerange",  "  0 usefont",  "  1 begincidrange",  "    <0000> <ffff> 0",  "  endcidrange",  "  endcmap",  "  currentdict CMapName exch /CMap defineresource pop",  "end",  "10 dict begin",  "  begincmap",  "  /CMapType 1 def",  "  /CMapName /Identity-V def",  "  /CIDSystemInfo 3 dict dup begin",  "    /Registry (Adobe) def",  "    /Ordering (Identity) def",  "    /Supplement 0 def",  "  end def",  "  /WMode 1 def",  "  1 begincodespacerange",  "    <0000> <ffff>",  "  endcodespacerange",  "  0 usefont",  "  1 begincidrange",  "    <0000> <ffff> 0",  "  endcidrange",  "  endcmap",  "  currentdict CMapName exch /CMap defineresource pop",  "end",  "end",  NULL};//------------------------------------------------------------------------// Fonts//------------------------------------------------------------------------struct PSSubstFont {  char *psName;			// PostScript name  double mWidth;		// width of 'm' character};static char *psFonts[] = {  "Courier",  "Courier-Bold",  "Courier-Oblique",  "Courier-BoldOblique",  "Helvetica",  "Helvetica-Bold",  "Helvetica-Oblique",  "Helvetica-BoldOblique",  "Symbol",  "Times-Roman",  "Times-Bold",  "Times-Italic",  "Times-BoldItalic",  "ZapfDingbats",  NULL};static PSSubstFont psSubstFonts[] = {  {"Helvetica",             0.833},  {"Helvetica-Oblique",     0.833},  {"Helvetica-Bold",        0.889},  {"Helvetica-BoldOblique", 0.889},  {"Times-Roman",           0.788},  {"Times-Italic",          0.722},  {"Times-Bold",            0.833},  {"Times-BoldItalic",      0.778},  {"Courier",               0.600},  {"Courier-Oblique",       0.600},  {"Courier-Bold",          0.600},  {"Courier-BoldOblique",   0.600}};// Info for 8-bit fontsstruct PSFont8Info {  Ref fontID;  Gushort *codeToGID;		// code-to-GID mapping for TrueType fonts};// Encoding info for substitute 16-bit fontstruct PSFont16Enc {  Ref fontID;  GString *enc;};//------------------------------------------------------------------------// process colors//------------------------------------------------------------------------#define psProcessCyan     1#define psProcessMagenta  2#define psProcessYellow   4#define psProcessBlack    8#define psProcessCMYK    15//------------------------------------------------------------------------// PSOutCustomColor//------------------------------------------------------------------------class PSOutCustomColor {public:  PSOutCustomColor(double cA, double mA,		   double yA, double kA, GString *nameA);  ~PSOutCustomColor();  double c, m, y, k;  GString *name;  PSOutCustomColor *next;};PSOutCustomColor::PSOutCustomColor(double cA, double mA,				   double yA, double kA, GString *nameA) {  c = cA;  m = mA;  y = yA;  k = kA;  name = nameA;  next = NULL;}PSOutCustomColor::~PSOutCustomColor() {  delete name;}//------------------------------------------------------------------------struct PSOutImgClipRect {  int x0, x1, y0, y1;};//------------------------------------------------------------------------// DeviceNRecoder//------------------------------------------------------------------------class DeviceNRecoder: public FilterStream {public:  DeviceNRecoder(Stream *strA, int widthA, int heightA,		 GfxImageColorMap *colorMapA);  virtual ~DeviceNRecoder();  virtual StreamKind getKind() { return strWeird; }  virtual void reset();  virtual int getChar()    { return (bufIdx >= bufSize && !fillBuf()) ? EOF : buf[bufIdx++]; }  virtual int lookChar()    { return (bufIdx >= bufSize && !fillBuf()) ? EOF : buf[bufIdx]; }  virtual GString *getPSFilter(int psLevel, char *indent) { return NULL; }  virtual GBool isBinary(GBool last = gTrue) { return gTrue; }  virtual GBool isEncoder() { return gTrue; }private:  GBool fillBuf();  int width, height;  GfxImageColorMap *colorMap;  Function *func;  ImageStream *imgStr;  int buf[gfxColorMaxComps];  int pixelIdx;  int bufIdx;  int bufSize;};DeviceNRecoder::DeviceNRecoder(Stream *strA, int widthA, int heightA,			       GfxImageColorMap *colorMapA):    FilterStream(strA) {  width = widthA;  height = heightA;  colorMap = colorMapA;  imgStr = NULL;  pixelIdx = 0;  bufIdx = gfxColorMaxComps;  bufSize = ((GfxDeviceNColorSpace *)colorMap->getColorSpace())->              getAlt()->getNComps();  func = ((GfxDeviceNColorSpace *)colorMap->getColorSpace())->           getTintTransformFunc();}DeviceNRecoder::~DeviceNRecoder() {  if (imgStr) {    delete imgStr;  }}void DeviceNRecoder::reset() {  imgStr = new ImageStream(str, width, colorMap->getNumPixelComps(),			   colorMap->getBits());  imgStr->reset();}GBool DeviceNRecoder::fillBuf() {  Guchar pixBuf[gfxColorMaxComps];  GfxColor color;  double x[gfxColorMaxComps], y[gfxColorMaxComps];  int i;  if (pixelIdx >= width * height) {    return gFalse;  }  imgStr->getPixel(pixBuf);  colorMap->getColor(pixBuf, &color);  for (i = 0;       i < ((GfxDeviceNColorSpace *)colorMap->getColorSpace())->getNComps();       ++i) {    x[i] = colToDbl(color.c[i]);  }  func->transform(x, y);  for (i = 0; i < bufSize; ++i) {    buf[i] = (int)(y[i] * 255 + 0.5);  }  bufIdx = 0;  ++pixelIdx;  return gTrue;}//------------------------------------------------------------------------// PSOutputDev//------------------------------------------------------------------------extern "C" {typedef void (*SignalFunc)(int);}static void outputToFile(void *stream, char *data, int len) {  fwrite(data, 1, len, (FILE *)stream);}PSOutputDev::PSOutputDev(char *fileName, XRef *xrefA, Catalog *catalog,			 int firstPage, int lastPage, PSOutMode modeA,			 int imgLLXA, int imgLLYA, int imgURXA, int imgURYA,			 GBool manualCtrlA) {  FILE *f;  PSFileType fileTypeA;  underlayCbk = NULL;

⌨️ 快捷键说明

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