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.