Clamp grayscale values to 0..1 for g operator

This commit is contained in:
Peter Williams 2018-07-06 16:29:54 +10:00
parent 606a271d00
commit e7433e4125

View File

@ -248,8 +248,11 @@ func (this *PdfColorspaceDeviceGray) ColorFromFloats(vals []float64) (PdfColor,
val := vals[0]
if val < 0.0 || val > 1.0 {
return nil, errors.New("Range check")
// Needed for ~/testdata/acl2017_hllz.pdf
if val < 0.0 {
val = 0.0
} else if val > 1.0 {
val = 1.0
}
return NewPdfColorDeviceGray(val), nil