private static int GetComponentsPerPixel(PdfName colorSpaceName, PdfDictionary colorSpaceDic)
{
if (colorSpaceName == null)
return 1;
if (colorSpaceName.Equals(PdfName.DEVICEGRAY))
return 1;
if (colorSpaceName.Equals(PdfName.DEVICERGB))
return 3;
if (colorSpaceName.Equals(PdfName.DEVICECMYK))
return 4;
if (colorSpaceDic != null){
PdfArray colorSpace = colorSpaceDic.GetAsArray(colorSpaceName);
if (colorSpace != null){
if (PdfName.INDEXED.Equals(colorSpace.GetAsName(0))){
return 1;
}
}
}
throw new ArgumentException("Unexpected color space " + colorSpaceName);
}