【问题标题】:error in conversion of raster file to postscript file将光栅文件转换为 postscript 文件时出错
【发布时间】:2016-06-08 15:22:14
【问题描述】:

我正在尝试将 PWG 光栅文件数据转换为 postscript 数据。我在测试文件中生成了如下:

%!PS-Adobe-3.0
%%BoundingBox: 0 0 5100 6600
%Creator: Cups-Filters
%LanguageLevel: 2
%DocumentData: Clean7Bit
%EndComments
%BeginProlog
%EndProlog

%Pages: (atend)
%%Page: 1 1
%%BeginPageSetup
<< /PageSize[5100 6600]/ImagingBBox null>> setpagedevice
%%EndPageSetup
gsave
gsave
5100 6600 scale
5100 6600 8 [5100 0 0 -6600 0 6600]
{currentfile 3 5100 string readhexstring pop} bind
false 3 colorimage

...hexadecimal information cut...

grestore
showpage
%PageTrailer
%Trailer
%%Pages: 1
%EOF

每当我尝试使用 GhostScript 解释器运行程序时,都会收到以下错误:

$ ghostscript sample.ps 
GPL Ghostscript 9.18 (2015-10-05)
Copyright (C) 2015 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Error: /typecheck in --colorimage--
Operand stack:
   --nostringval--   3   (\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000...)
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1977   1   3   %oparray_pop   1976   1   3   %oparray_pop   1960   1   3   %oparray_pop   1852   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   1878   7   3   %oparray_pop
Dictionary stack:
   --dict:1194/1684(ro)(G)--   --dict:0/20(G)--   --dict:78/200(L)--
Current allocation mode is local
Current file position is 399
GPL Ghostscript 9.18: Unrecoverable error, exit code 1

PS 文件大约 128 MB,其中大约 99% 的数据是彩色图像的十六进制表示。

我尝试搜索它,一个来源建议将“setpagedevice”参数添加到 PS 文件中。我已经添加了它,但没有效果。

我怎样才能摆脱这个错误?另外,有没有其他方法可以在 postscript 中表示非常大的图像?

【问题讨论】:

  • 你试过在{currentfile 3 5100 string readhexstring pop}之后不绑定吗?我在PSLRM中没有看到它的绑定@
  • bind 应该不会导致问题,所发生的只是在绑定时将操作符定义替换为它们的当前值。因此,如果您重新定义,例如,在过程之后但在执行过程之前重新定义 readhexstring,您将获得不同的结果,无论是否绑定。我建议问题是读取数据的代码。见下文。

标签: ghostscript postscript


【解决方案1】:

您的代码包含:

{currentfile 3 5100 string readhexstring pop} bind

如果我们将其分解并添加关于我们获得的堆栈内容的 cmets:

{
  currentfile    % Stack contents: -file-
  3              % stack contents: -file- 3
  5100           % stack contents: -file- 3 5100
  string         % string consumes the top operand, creates a string
                 % object of that size, and places the string on the stack
                 % stack contains: -file- 3 (string)
  readhexstring  % consume string and file operands, return substring, bool
                 %
  pop            % pop the boolean
}

问题是 readhexstring 期望看到 -file-(字符串),但堆栈实际上包含 3(字符串),3 不是文件对象,因此您会收到类型检查错误。

【讨论】:

  • 这很有帮助(即使对于我正在努力解决的其他事情)。我删除了“3”,现在一切正常。谢谢
猜你喜欢
  • 2017-04-07
  • 2019-01-08
  • 1970-01-01
  • 2016-01-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多