2016-06-08 13 views
3

PWG 래스터 파일 데이터를 포스트 스크립트 데이터로 변환하려고합니다. 나는 다음과 같다 테스트 파일에 생성 한 :래스터 파일을 포스트 스크립트 파일로 변환하는 중 오류가 발생했습니다.

%!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 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 

추신 파일이 약 1백28메가바이트입니다 약 99 %의 데이터는 컬러 이미지의 16 진수 표현입니다.

PS 파일에 'setpagedevice'매개 변수를 추가하는 것이 좋습니다. 나는 그것을 추가했지만 효과가 없다.

이 오류를 제거하려면 어떻게해야합니까? 또한 포스트 스크립트에서 매우 큰 이미지를 표현하는 다른 방법이 있습니까?

+0

'{currentfile 3 5100 string readhexstring pop}'다음에 바인드하지 않고 해봤습니까? [PSLRM] (https://www.adobe.com/products/postscript/pdfs/PLRM.pdf)의 바인드와 함께 표시되지 않습니다. –

+0

바인드로 인해 문제가 발생하지 않아야합니다. 모든 문제는 운영자 정의가 바인딩시의 현재 값으로 대체됩니다. 예를 들어 프로 시저 뒤에 readhexstring을 다시 정의했지만 프로 시저를 실행하기 전에 바인딩을 사용하거나 사용하지 않은 경우 결과가 달라집니다. 나는 문제가 데이터를 읽는 코드라고 제안한다. 아래를 참조하십시오. – KenS

답변

2

코드는 포함

{currentfile 3 5100 string readhexstring pop} bind 

우리가 헤어지고 스택의 콘텐츠 우리가 얻을에 대한 의견을 추가하는 경우 :

{ 
    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은 파일 객체가 아니므로 유형 검사 오류가 발생합니다.

+0

많은 도움이되었습니다 (심지어 내가 고심하고있는 다른 것들에도 도움이되었습니다). 나는 '3'을 제거했고 모든 것이 이제는 잘 작동합니다. 감사 – Pranjal