[ 
https://issues.apache.org/jira/browse/PDFBOX-2570?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14247289#comment-14247289
 ] 

John Hewson edited comment on PDFBOX-2570 at 12/15/14 9:59 PM:
---------------------------------------------------------------

Ok, great, I see. Looks like ICCBased was a later addition to PDF, so it's the 
odd one out. There's no real need for CalGray to extend CalRGB, even though 
CalGray is logically just a special case of CalRGB. One advantage of not doing 
so is that the calculations for grayscale images will be faster with dedicated 
grayscale code.

Neither of the CalXXX color spaces have received much attention, e.g. I notice 
that getGammaMatrix should be getMatrix - the matrix specifies an arbitrary 
transform and not gamma itself. This is a legacy from old 1.8 code.


was (Author: jahewson):
Ok, great, I see. Looks like ICCBased was a later addition to PDF, so it's the 
odd one out. There's no real need for CalGray to extend CalRGB, even though 
CalGray is logically just a special case of CalRGB. One advantage of not doing 
so is that the calculations for grayscale images will be faster with dedicated 
grayscale code.

Neither of the CalXXX color spaces have received much attention, I notice that 
getGammaMatrix should be getMatrix - the matrix specifies an arbitrary 
transform and not gamma itself. This is a legacy from old 1.8 code.

> ClassCastException in PDCalGray: COSFloat cannot be cast to COSArray
> --------------------------------------------------------------------
>
>                 Key: PDFBOX-2570
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-2570
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Parsing
>    Affects Versions: 2.0.0
>            Reporter: Tilman Hausherr
>              Labels: CalGray, CalRGB, regression
>             Fix For: 2.0.0
>
>
> {code}
> INFORMATION: Rendering: PDFBOX-1724.pdf
> java.lang.ClassCastException: org.apache.pdfbox.cos.COSFloat cannot be cast 
> to org.apache.pdfbox.cos.COSArray
>       at 
> org.apache.pdfbox.pdmodel.graphics.color.PDCalRGB.getGamma(PDCalRGB.java:158)
>       at 
> org.apache.pdfbox.pdmodel.graphics.color.PDCalRGB.toRGB(PDCalRGB.java:95)
>       at 
> org.apache.pdfbox.pdmodel.graphics.color.PDCalGray.toRGB(PDCalGray.java:81)
>       at 
> org.apache.pdfbox.pdmodel.graphics.color.PDCIEBasedColorSpace.toRGBImage(PDCIEBasedColorSpace.java:88)
> {code}
> The cause is that in one of the redesigns it was overseen that the Gamma is a 
> single value for CalGray, and not an array like in CalRGB. Thus PDCalGray 
> cannot be extended from PDCalRGB. The bug didn't have an effect because the 
> gamma wasn't used before PDFBOX-2553. Instead I will extend it from 
> PDCIEBasedColorSpace or from a new abstract class PDCalBasedColorSpace.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to