gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 10:30:40 26 4
gpt4 key购买 nike

我正在尝试在 postscript 中编写文档。

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

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

下面的片段是一个 Hello World :

%!PS
/Times
20 selectfont
20 800 moveto
(Hello World!) show
showpage

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

任何帮助将非常感激。

最佳答案

有一个简单的方法,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

关于image - 在 postscript 中添加图像的简单方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4968443/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com