I have written a C code to generate postscript files from PWG raster files. The output is working on (format is color model - bit depth): 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. But the output of adobergb-16 and sgray-16 given is wrong. I get the pattern similar to the input file but the colors are all pixelated.
Actual code is very big, so I am posting what I did:
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
For adobergb-16 I am setting PS colorspace to /DeviceRGB
and the decode array is /Decode [0 1 0 1 0 1]
.
For sgray-16 I am setting the PS colorspace to /DeviceGray
and the decode is /Decode [0 1]
These setting are similar to adobergb-8 and sgray-8.
EDIT 1: Adding the example files I used to test HERE
If you want any further information or the code snippets, please feel free to ask.
Well you've set "/BitsPerComponent 16"; as I said above, that's not a legal value, since PostScript only supports 1, 2, 4, 8 and 12 bits per component.
Running this file through Adobe Acrobat Distiller gives:
%%[ Error: rangecheck; OffendingCommand: imageDistiller; ErrorInfo: BitsPerComponent 16 ]%%
Rewriting your image like this:
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
Sets the BitsPerComponent to 8, discards the top byte of every 16-bit value, and the output works as expected.
When I said 'a nice simple small example' I didn't mean 30 MB of data, that is not necessary to exhibit the problem I am certain. When posting examples make a simple, small, example and use that. I haven't bothered to download your other files.
To reiterate; you cannot set /BitsPerComponent 16, PostScript does not support 16 bits per component.