后记图像在某些颜色模型上输出错误

Postscript image output wrong on some color models

我已经编写了一个 C 代码来从 PWG 光栅文件生成 postscript 文件。输出正在处理(格式为颜色模型 - 位深度):black-1, black-8, black-16, rgb-8, rgb-16, gray-1, gray-8, gray-16, srgb-8 , srgb-16, adobergb-8, sgray-1, sgray-8, cmyk-1, cmyk-8, cmyk-16。 但是给出的 adobergb-16 和 sgray-16 的输出是错误的。我得到的图案与输入文件相似,但颜色都是像素化的。

实际代码量很大,所以我贴一下我做的:

take all the image pixels in an unsigned char* variable (this sometimes becomes very large)

encode the pixels using deflate algorithm from zlib

display the result

对于 adobergb-16,我将 PS 色彩空间设置为 /DeviceRGB,解码数组为 /Decode [0 1 0 1 0 1]。 对于 sgray-16,我将 PS 色彩空间设置为 /DeviceGray,解码为 /Decode [0 1] 这些设置类似于adobergb-8和sgray-8。

编辑 1: 添加我用来测试的示例文件 HERE

如果您需要任何进一步的信息或代码片段,请随时询问。

你已经设置了“/BitsPerComponent 16”;正如我上面所说,这不是合法值,因为 PostScript 仅支持每个组件 1、2、4、8 和 12 位。

运行 这个文件通过 Adob​​e Acrobat Distiller 给出:

%%[ 错误:范围检查;违规命令:imageDistiller;错误信息:BitsPerComponent 16]%%

像这样重写你的图像:

gsave
/DeviceRGB setcolorspace
/Input currentfile /FlateDecode filter def
4958 7017 scale
<< 
/ImageType 1
/Width 4958
/Height 7017
/BitsPerComponent 8
/Decode [0 1 0 1 0 1]
/DataSource {3 string 0 1 2 {1 index exch Input read {pop}if Input read pop put } for} bind
/ImageMatrix [4958 0 0 -7017 0 7017]
>> image

将 BitsPerComponent 设置为 8,丢弃每个 16 位值的最高字节,输出按预期工作。

当我说 'a nice simple small example' 时,我并不是说 30 MB 的数据,我确信这不是显示问题所必需的。在发布示例时,制作一个简单的小示例并使用它。我没有费心去下载你的其他文件。

重申; 您不能设置 /BitsPerComponent 16,PostScript 不支持每个组件 16 位。