protected void validImageColorSpace(Operator operator) throws IOException
{
COSDictionary dict = operator.getImageParameters();
COSBase csInlinedBase = dict.getItem(COSName.CS);
ColorSpaceHelper csHelper = null;
if (csInlinedBase != null)
{
if (COSUtils.isString(csInlinedBase, cosDocument))
{
// In InlinedImage only DeviceGray/RGB/CMYK and restricted Indexed
// color spaces are allowed.
String colorSpace = COSUtils.getAsString(csInlinedBase, cosDocument);
ColorSpaces cs = null;
try
{
cs = ColorSpaces.valueOf(colorSpace);
}
catch (IllegalArgumentException e)
{
// The color space is unknown. Try to access the resources dictionary,
// the color space can be a reference.
PDColorSpace pdCS = this.getResources().getColorSpace(COSName.getPDFName(colorSpace));
if (pdCS != null)
{
cs = ColorSpaces.valueOf(pdCS.getName());
PreflightConfiguration cfg = context.getConfig();
ColorSpaceHelperFactory csFact = cfg.getColorSpaceHelperFact();
csHelper = csFact.getColorSpaceHelper(context, pdCS, ColorSpaceRestriction.ONLY_DEVICE);
}
}
if (cs == null)
{
registerError("The ColorSpace is unknown", ERROR_GRAPHIC_UNEXPECTED_VALUE_FOR_KEY);
return;
}
}
if (csHelper == null)
{
PDColorSpace pdCS = PDColorSpace.create(csInlinedBase);
PreflightConfiguration cfg = context.getConfig();
ColorSpaceHelperFactory csFact = cfg.getColorSpaceHelperFact();
csHelper = csFact.getColorSpaceHelper(context, pdCS, ColorSpaceRestriction.ONLY_DEVICE);
}
csHelper.validate();
}
}