在postscript中添加图像的简单方法

Dar*_*ght 7 image postscript

我想在postscript中写一个文件.

到目前为止,我已经能够编写简单的文本,并使用线条和形状.

我现在正试图在文档中添加一些图像.在线搜索后,我似乎找不到任何明确的方法来做到这一点.

下面的剪辑是一个问候世界:

%!PS
/Times               
20 selectfont         
20 800 moveto         
(Hello World!) show
showpage 
Run Code Online (Sandbox Code Playgroud)

我想要做的只是通过指定x和y坐标来插入图像(例如PNG,JPG,GIF).

任何帮助将非常感激.

Hat*_*995 10

有一个简单的方法,Postscript支持jpeg格式.如果您使用的是ghostscript,则可能必须使用-dNOSAFER选项来打开文件.这是一个例子:

gsave
 360 72 translate     % set lower left of image at (360, 72)
  175 47 scale         % size of rendered image is 175 points by 47 points
  500                   % number of columns per row
  133                    % number of rows
  8                    % bits per color channel (1, 2, 4, or 8)
  [500 0 0 -133 0 133]       % transform array... maps unit square to pixel
  (myJPEG500x133.jpg) (r) file /DCTDecode filter % opens the file and filters the image data
  false                 % pull channels from separate sources
  3                    % 3 color channels (RGB)
  colorimage
grestore
Run Code Online (Sandbox Code Playgroud)