public Color GetColor(int index) { var componentIndex = index * componentsCount; var components = new PdfDirectObject[componentsCount]; for (int i = 0; i < componentsCount; i++) { var value = componentIndex < buffer.Length ? buffer[componentIndex] : 0; var interpolate = indexed ? value : min + (value * ((max - min) / maximum)); components[i] = indexed ? (PdfDirectObject) new PdfInteger((int)interpolate) : (PdfDirectObject) new PdfReal(interpolate); componentIndex++; } return(colorSpace.GetColor(components, null)); }