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

📄 viewpbm.ps

📁 遗传算法工具箱 希望高手指点 GATOOLS
💻 PS
字号:
%    Copyright (C) 1992, 1995, 1996 Aladdin Enterprises.  All rights reserved.
%
% This file is part of Ghostscript.
%
% Ghostscript is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
% to anyone for the consequences of using it or for whether it serves any
% particular purpose or works at all, unless he says so in writing.  Refer
% to the Ghostscript General Public License for full details.
%
% Everyone is granted permission to copy, modify and redistribute
% Ghostscript, but only under the conditions described in the Ghostscript
% General Public License.  A copy of this license is supposed to have been
% given to you along with Ghostscript so you can know your rights and
% responsibilities.  It should be in a file named COPYING.  Among other
% things, the copyright notice and this notice must be preserved on all
% copies.

% viewpbm.ps
% Display a PBM/PGM/PPM file.
% Requires the Level 2 `image' operator (to handle variable pixel widths).
% If SCALE is defined, maps input pixels to output pixels with that scale;
% if SCALE is undefined, scales the image to fit the page.

/s 100 string def
/readmaxv
 { f s readline pop cvx exec /maxv exch def
 } bind def
/readrow
 { 0 1 row length 1 sub { row exch f token pop put } for
 } bind def
/read01			% <count> read01 <byte>
 { 0 exch { f read pop 48 xor dup 1 le { exch dup add add } { pop } ifelse } repeat
 } bind def
/P1			% ASCII 1-bit white/black
 {	{ /bpc 1 def /maxv 1 def /rsize w 7 add 8 idiv def
	  /wrem w 8 mod def
          /ncomp 1 def /invert true def
	}
	{ 0 1 w 8 idiv { row exch 8 read01 put } for
	  wrem 0 ne
	   { row rsize 1 sub wrem read01 8 wrem sub bitshift put
	   } if
	  row
	}
   runpbm
 } bind def
/P2			% ASCII 8-bit gray
 {	{ /bpc 8 def readmaxv /rsize w def
	  /ncomp 1 def /invert false def
	}
	{ readrow row }
   runpbm
 } bind def
/P3			% ASCII 8-bit RGB
 {	{ /bpc 8 def readmaxv /rsize w 3 mul def
          /ncomp 3 def /invert false def /DeviceRGB setcolorspace
	}
	{ readrow row }
   runpbm
 } bind def
/P4			% Binary 1-bit white/black
 {	{ /bpc 1 def /maxv 1 def /rsize w 7 add 8 idiv def
	  /ncomp 1 def /invert true def
	}
	{ f row readstring pop }
   runpbm
 } bind def
/P5			% Binary 8-bit gray
 {	{ /bpc 8 def readmaxv /rsize w def
	  /ncomp 1 def /invert false def
	}
	{ f row readstring pop }
   runpbm
 } bind def
/P6			% Binary 8-bit RGB
 {	{ /bpc 8 def readmaxv /rsize w 3 mul def
	  /ncomp 3 def /invert false def /DeviceRGB setcolorspace
	}
	{ f row readstring pop }
   runpbm
 } bind def
/viewpbm { run } def
/runpbm				% <initproc> <readproc> runpbm -
 { /readproc exch def
   /initproc exch def
   currentfile /f exch def
   f s readline pop		% check for comment
   (#) anchorsearch
    { pop pop f s readline pop }
   if
   cvx exec /h exch def /w exch def
   erasepage
   /DeviceGray setcolorspace
   initproc			% sets bpc, maxv, rsize, ncomp, invert
   /row rsize string def
   /SCALE where
    { pop
	% Map pixels SCALE-for-1.  Assume orthogonal transformation.
      w 1 0 dtransform add abs div SCALE mul
      h 0 1 dtransform add abs div SCALE mul
    }
    {	% Scale the image (uniformly) to fit the page.
      clippath pathbbox pop pop translate
      pathbbox min exch pop exch pop ceiling
      dup h mul w div
    }
   ifelse scale
   20 dict begin		% image dictionary
     /ImageType 1 def
     /Width w def
     /Height h def
     /ImageMatrix [w 0 0 h neg 0 h] def
     /BitsPerComponent bpc def
     /Decode [ 0 255 maxv div invert { exch } if ncomp 1 sub { 2 copy } repeat ] def
     /DataSource /readproc load def
   currentdict end
   image
   showpage
 } def

% If the program was invoked from the command line, run it now.
[ shellarguments
 { counttomark 1 ge
    { ] { viewpbm } forall
    }
    { cleartomark
      (Usage: gs [--] viewpbm.ps filename.p*m ...\n) print
      ( e.g.: gs [--] viewpbm.ps my.ppm another.ppm\n) print flush
    }
   ifelse
 }
 { pop
 }
ifelse

⌨️ 快捷键说明

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