Bug 702135 - Halftone angle inverted in specific situations on tiffsep1
Summary: Halftone angle inverted in specific situations on tiffsep1
Status: RESOLVED LATER
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: Color (show other bugs)
Version: 9.50
Hardware: PC Linux
: P4 normal
Assignee: Michael Vrhel
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-19 09:11 UTC by Martin Schulze
Modified: 2023-05-23 16:54 UTC (History)
1 user (show)

See Also:
Customer:
Word Size: ---


Attachments
Comparison of angles for accurate screens with frequency 150 and resolutuion 600,720,750 DPI (23.97 KB, image/png)
2020-02-19 09:11 UTC, Martin Schulze
Details
Modified sample file with pointed spot function. (288 bytes, application/postscript)
2020-12-29 02:31 UTC, Peter Cherepanov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Schulze 2020-02-19 09:11:07 UTC
Created attachment 18872 [details]
Comparison of angles for accurate screens with frequency 150 and resolutuion 600,720,750 DPI

When using the device tiffsep1 with `/AccurateScreens true` I get inverted angles when the frequency is not a divisor of the resolution.

```
%!PS-Adobe-3.0

<<
/HalftoneType 1
/Frequency 150
/Angle 75
/SpotFunction { abs exch abs 2 copy add 1 gt { 1 sub dup mul exch 1 sub dup mul add 1 sub } { dup mul exch dup mul add 1 exch sub } ifelse }
/AccurateScreens true
>> /Default exch /Halftone defineresource sethalftone
<< /PageSize [10 10] >> setpagedevice
0.75 0.5 0 0 setcmykcolor
newpath 0 0 moveto 10 0 lineto 10 10 lineto 0 10 lineto closepath fill 
showpage
```

Running this with `gs -dBATCH -dNOPAUSE -sDEVICE=tiffsep1 -sOutputFile=test-720.tif -r720 -f test.ps` results in inverted angles compared to the results of `-r600` or `-r750`.


-----------------------------------------------


Additionally, I noticed a similar flip when using no accurate screens and having a large factor between frequency and resolution. Bisecting on the resolution (with `gs -dBATCH -dNOPAUSE -sDEVICE=tiffsep1 -sOutputFile=test2-465.tif -r465 -f test2.ps`) for the following file pinned down the flip bewteen `-r465` and `-r466`:

```
%!PS-Adobe-3.0
<<
/HalftoneType 1
/Frequency 20
/Angle 75
/SpotFunction { abs exch abs 2 copy add 1 gt { 1 sub dup mul exch 1 sub dup mul add 1 sub } { dup mul exch dup mul add 1 exch sub } ifelse }
%/AccurateScreens true
>> /Default exch /Halftone defineresource sethalftone

<< /PageSize [10 10] >> setpagedevice
0.75 0.5 0 0 setcmykcolor
newpath 0 0 moveto 10 0 lineto 10 10 lineto 0 10 lineto closepath fill 
showpage
```

Similarly, a flip can be pinned down when using no halftone dictionary but setting `-dDITHERPPI` with `gs -dBATCH -dNOPAUSE -sDEVICE=tiffsep1 -sOutputFile=test3-966.tif -r966 -dDITHERPPI=20 -f test3.ps` and the following file:

```
%!PS-Adobe-3.0
<< /PageSize [10 10] >> setpagedevice
0.75 0.5 0 0 setcmykcolor
newpath 0 0 moveto 10 0 lineto 10 10 lineto 0 10 lineto closepath fill 
showpage
```

The flip happens between `-r966` and `-r967`.
Comment 1 Ken Sharp 2020-03-08 01:05:48 UTC
Assigning to Ray as this is very similar to the problem fixed in this commit:

http://git.ghostscript.com/?p=ghostpdl.git;a=commit;h=bf689ee0bff720f202ebc98f301c765f34e2c1fa

FWIW its possible the accurate screens case is fixed, though its hard to be sure on such a small sample. The regular screens case is more obviously incorrect.
Comment 2 Peter Cherepanov 2020-12-29 02:31:21 UTC
Created attachment 20408 [details]
Modified sample file with pointed spot function.

I confirm that there's a flip between 465 and 466 dpi. One is rotated clockwise, another is rotated counter-clockwise. 

The spot function in my halftone draws an isosceles triangle. The halftone angle is a negative of the angle between X axis and a line of symmetry of the triangle.  Negation is needed because halftone angles are measured clockwise.