Bug 691131

Summary: Remaining errors with icc_work branch
Product: Ghostscript Reporter: Marcos H. Woehrmann <marcos.woehrmann>
Component: ColorAssignee: Michael Vrhel <michael.vrhel>
Status: RESOLVED FIXED    
Severity: normal CC: christinedelight.top85, cloos
Priority: P4    
Version: 0.00   
Hardware: PC   
OS: Linux   
Customer: Word Size: ---
Attachments: 871_cie_r100_cmyk.png
871_cie_r100_cmyk2.png
871_cie_r100_cmyk4.png
871_cie_r100_cmyk8.png
871_r100_cmyk.png
871_r100_cmyk2.png
871_r100_cmyk4.png
871_r100_cmyk8.png
icc_cie_r100_cmyk.png
icc_cie_r100_cmyk2.png
icc_cie_r100_cmyk4.png
icc_cie_r100_cmyk8.png
icc_r100_cmyk2.png
icc_r100_cmyk4.png
icc_r100_cmyk8.png
This is based on colorcir.ps, using cmyk colours, excluding the cicles

Description Marcos H. Woehrmann 2010-02-22 15:15:42 UTC
There are a few files that are still producing errors with the current icc_work
branch (r10783):

Never finishes:
gs -o test.pdf -sDEVICE=pdfwrite -r72 ./tests_private/comparefiles/Bug689189.pdf
gs -o test.ppm -sDEVICE=ppmraw   -r72 ./test.pdf

/typecheck in run:
gs -o test.pdf -sDEVICE=pdfwrite -r72 ./tests_private/comparefiles/Bug690164.ps
gs -o test.ppm -sDEVICE=ppmraw   -r72 ./test.pdf

/typecheck in run:
gs -o test.pdf -sDEVICE=pdfwrite -r72 ./tests_private/ps/ps3cet/15-05.PS
gs -o test.ppm -sDEVICE=ppmraw   -r72 ./test.pdf

seg fault:
gs -o test.pbm -sDEVICE=pbmraw -r72 -dJOBSERVER
./tests_private/pdf/PDFIA1.7_SUBSET/CATX4373.pdf

seg fault:
gs -o test.pbm -sDEVICE=pbmraw -r72 -dJOBSERVER
./tests_private/pdf/PDFIA1.7_SUBSET/IA3Z0070.pdf
Comment 1 James Cloos 2010-02-24 12:37:29 UTC
The rendering of fonts when viewing via the x11cmyk{,2,4,8} devices is often
corrupted.

That corruption is worse when using the icc_work branch than it is with 8.71,
especially when using -dUseCIEColor.

Comment 2 Hin-Tak Leung 2010-02-24 15:47:46 UTC
regarding issues with x11cmyk{,2,4,8}, care to provide some screenshots? 

It might be useful to look at x11cmyk in combination with Bug 690998 (icc_work
branch also shows more problem at color depth 15/16 with x11 than trunk, vs
depth 24).
Comment 3 James Cloos 2010-02-28 09:25:47 UTC
In the following attachments, the filenames start with 871 for 8.71 or icc for
the icc_work branch; those done with UseCIEColor have cie in the filename; r100
is for -r100 and the last component is the DEVICE, with "x11" elided.

The corruption happens for all text when the resolution is in [77,106] dpi. 
Outside of that range it renders OK.

The colours are all off for the 2bit and 4bit devices; it looks like the
dithering is wrong.  In the 2bit case, if you render tiger the orange is
dithered with black rather than with white; perhaps the polarity is wrong?

In the 4bit case, the dithering results in mostly just black; sometimes a single
splash of colour will show up, such as the center line of tiger's tongue or a
bit of darker orange just over its nose.
Comment 4 James Cloos 2010-02-28 09:28:12 UTC
Created attachment 6003 [details]
871_cie_r100_cmyk.png
Comment 5 James Cloos 2010-02-28 09:28:43 UTC
Created attachment 6004 [details]
871_cie_r100_cmyk2.png
Comment 6 James Cloos 2010-02-28 09:29:05 UTC
Created attachment 6005 [details]
871_cie_r100_cmyk4.png
Comment 7 James Cloos 2010-02-28 09:29:44 UTC
Created attachment 6006 [details]
871_cie_r100_cmyk8.png
Comment 8 James Cloos 2010-02-28 09:30:12 UTC
Created attachment 6007 [details]
871_r100_cmyk.png
Comment 9 James Cloos 2010-02-28 09:30:37 UTC
Created attachment 6008 [details]
871_r100_cmyk2.png
Comment 10 James Cloos 2010-02-28 09:30:59 UTC
Created attachment 6009 [details]
871_r100_cmyk4.png
Comment 11 James Cloos 2010-02-28 09:31:35 UTC
Created attachment 6010 [details]
871_r100_cmyk8.png
Comment 12 James Cloos 2010-02-28 09:32:10 UTC
Created attachment 6011 [details]
icc_cie_r100_cmyk.png
Comment 13 James Cloos 2010-02-28 09:32:38 UTC
Created attachment 6012 [details]
icc_cie_r100_cmyk2.png
Comment 14 James Cloos 2010-02-28 09:33:02 UTC
Created attachment 6013 [details]
icc_cie_r100_cmyk4.png
Comment 15 James Cloos 2010-02-28 09:33:32 UTC
Created attachment 6014 [details]
icc_cie_r100_cmyk8.png
Comment 16 James Cloos 2010-02-28 09:34:01 UTC
Created attachment 6015 [details]
icc_r100_cmyk2.png
Comment 17 James Cloos 2010-02-28 09:34:32 UTC
Created attachment 6016 [details]
icc_r100_cmyk4.png
Comment 18 James Cloos 2010-02-28 09:34:59 UTC
Created attachment 6017 [details]
icc_r100_cmyk8.png
Comment 19 James Cloos 2010-03-02 10:12:34 UTC
I forgot to mention that the icc_work gs will only look for the iccprofiles
directory in $CWD and %rom%.  It does not search in $gsdatadir or any of the
directoried in $GS_LIB or $GS_LIB_DEFAULT.  Nor does make install install them
anywhere.

This is understandable presuming Mike uses %rom% or always runs tests from the
root dir of a checkout, but use of %rom% is not common on Linux or BSD distro
builds and I doubt that I am unusual in also not using it for test builds.

Also, here is the ps I used for the screenshots:

%!
/Times-Bold findfont 24 scalefont setfont
gsave
 2 60 translate 0 0 moveto 0 1 1 0 setcmykcolor (Red) show
54 0 translate 0 0 moveto 1 0 1 0 setcmykcolor (Green) show
72 0 translate 0 0 moveto 1 1 0 0 setcmykcolor (Blue) show
grestore
gsave
2 36 translate 0 0 moveto 1 0 0 0 setcmykcolor (Cyan) show
60 0 translate 0 0 moveto 0 1 0 0 setcmykcolor (Magenta) show
96 0 translate 0 0 moveto 0 0 1 0 setcmykcolor (Yellow) show
grestore
gsave
2 6 translate 0 0 moveto 0 0 0 0.1 setcmykcolor ('White') show
96 0 translate 0 0 moveto 0 0 0 1 setcmykcolor (Black) show
grestore

showpage

based on examples/colorcir.ps.  

Interestingly, using x11cmyk{,8} to view pdf or ps output from cairo from
printing a filled-out pdf from evince does not show the anomolies that the ps
above does.  At least not at 96 or 100 dpi.  x11cmyk{2,4} still have problems
dithering.

Oh, and if I change that PS above to use 36 pt Times-Bold instead of 24 pt the
corruption also vanishes.

So the bug I see is not just dpi dependent, but font px/em dependent.

Further testing shows that using a type1 font found by name in the Resource/Font
directory rather than via Fontmap can change the colours if UseCIEColor is set
(at least after today’s commits).
Comment 20 Michael Vrhel 2010-06-28 11:02:36 UTC
James Cloos,

Please provide the source document that created these, or better yet re-run since there have been many changes since the icc branch has been merged into the trunk.
Comment 21 James Cloos 2010-06-28 15:37:05 UTC
Created attachment 6409 [details]
This is based on colorcir.ps, using cmyk colours, excluding the cicles

This is the ps file I used to generate those  PNGs.

It is based on examples/colorcir.ps; rendering just the coloured names, but using setcmykcolor instead of setrgbcolor.

At one point, the icc branch was slow enought that I could see, when rendering cmykcolorcir.ps (colorcir.ps with setrgbcolor calls changed to setcmyk calls),
that the text was rendered OK at first, and only messed up later.

It’ll be a few hours before I can test out the current trunk with these.  I’ll be able to try it out on both 32bit and 64bit when I do.
Comment 22 James Cloos 2010-06-28 16:51:39 UTC
I was able to get to it sooner than I had thought.  At least for the 64 bit box.

The bug is still there in trunk.  Given its age, it may be specific to how the x11cmyk device uses its framebuffer?

Also, it could not find the iccprofiles dir no matter where I installed it under $prefix/share/ghostscript.  I tried each of these:

$prefix/share/ghostscript/iccprofiles
$prefix/share/ghostscript/8.72/iccprofiles
$prefix/share/ghostscript/8.72/Resources/iccprofiles
./iccprofiles

It used to work in $prefix/share/ghostscript/8.72/iccprofiles  and ./iccprofiles before the merge.

I had to link the icc files themselves into $PWD in order to UseCIEColor,
so the --disable-compile-inits case remains kaputt.
Comment 23 James Cloos 2010-06-28 17:07:52 UTC
And here is an example command line:

:; for ij in $(seq 50 110);do icon "dpi=${ij}"; /opt/iccgs/bin/gs -r${ij} -g$[ij * 3]x$[ij * 5 / 4 + 1] -dBATCH  -sDEVICE=x11cmyk -dUseCIEColor cmyknames.ps ; done

The corruption shows up at -r lower than 107.  

It takes about 800 dpi or more clearly to see the halftone which the x11cmyk device tries to use.  At 300 dpi you can see how that halftone is "squeezed".  My guess is that at below 108 dpi it get fuddled beyond recognition.

(It took me a bit today to fully remember the details.)
Comment 24 James Cloos 2010-06-29 15:54:07 UTC
I just noticed that the rendering bug also shows up when using the x11mono device.
The threshold is the same:  <107 dpi fails, >=107 dpi is OK.

I think that confirms that the bug is due to how halftones are done.
Comment 25 James Cloos 2011-06-23 11:44:57 UTC
The image corruption shown in my screenshots above is gone (I tested gs-9.02 and yesterday’s ghostpdl-master).

Using the x11cmyk device, though, master does not halftone the text the way gs used to; that may be why the corruption no longer occurs.
Comment 26 Marcos H. Woehrmann 2011-06-27 17:24:40 UTC
The problems listed in the Comment #0 no longer occur with head (9b9d97a5a2c299595048c72fa10e1a2b2845ff58) and so I'm closing this bug.  

If there are any issues remaining with the cmyk output as listed in comments #1 through #24 please open an independent bug (as should have been done in the first place).

(In reply to comment #0)
> There are a few files that are still producing errors with the current icc_work
> branch (r10783):
> 
> Never finishes:
> gs -o test.pdf -sDEVICE=pdfwrite -r72 ./tests_private/comparefiles/Bug689189.pdf
> gs -o test.ppm -sDEVICE=ppmraw   -r72 ./test.pdf
> 
> /typecheck in run:
> gs -o test.pdf -sDEVICE=pdfwrite -r72 ./tests_private/comparefiles/Bug690164.ps
> gs -o test.ppm -sDEVICE=ppmraw   -r72 ./test.pdf
> 
> /typecheck in run:
> gs -o test.pdf -sDEVICE=pdfwrite -r72 ./tests_private/ps/ps3cet/15-05.PS
> gs -o test.ppm -sDEVICE=ppmraw   -r72 ./test.pdf
> 
> seg fault:
> gs -o test.pbm -sDEVICE=pbmraw -r72 -dJOBSERVER
> ./tests_private/pdf/PDFIA1.7_SUBSET/CATX4373.pdf
> 
> seg fault:
> gs -o test.pbm -sDEVICE=pbmraw -r72 -dJOBSERVER
> ./tests_private/pdf/PDFIA1.7_SUBSET/IA3Z0070.pdf