Skip to content

Commit

Permalink
PDFBOX-5882: add warning if component count doesn't match colorspace
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1921186 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
THausherr committed Oct 8, 2024
1 parent a773bea commit 8e43dc9
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ public PDColor(float[] components, PDColorSpace colorSpace)
this.components = components.clone();
this.patternName = null;
this.colorSpace = colorSpace;
if (colorSpace != null && colorSpace.getNumberOfComponents() != components.length)
{
// PDFBOX-5882
LOG.warn("Colorspace component count {} doesn't match components length {}",
colorSpace.getNumberOfComponents(),
components.length);
}
}

/**
Expand All @@ -129,6 +136,16 @@ public PDColor(float[] components, COSName patternName, PDColorSpace colorSpace)
this.components = components.clone();
this.patternName = patternName;
this.colorSpace = colorSpace;
if (colorSpace instanceof PDPattern)
{
PDColorSpace ucs = ((PDPattern) colorSpace).getUnderlyingColorSpace();
if (ucs != null && ucs.getNumberOfComponents() != components.length)
{
// PDFBOX-5882
LOG.warn("Pattern colorspace component count {} doesn't match components length {}",
ucs.getNumberOfComponents(), components.length);
}
}
}

/**
Expand Down

0 comments on commit 8e43dc9

Please sign in to comment.