public override SKColor GetColor(Color color, double?alfa)
        {
            IList <PdfDirectObject> alternateColorComponents = TintFunction.Calculate(color.Components);
            ColorSpace alternateSpace = AlternateSpace;

            return(alternateSpace.GetColor(alternateSpace.GetColor(alternateColorComponents, null), alfa));
        }
Ejemplo n.º 2
0
        /**
         * <summary>Gets the color corresponding to the specified table index resolved according to
         * the <see cref="BaseSpace">base space</see>.<summary>
         */
        public Color GetBaseColor(IndexedColor color)
        {
            int colorIndex = color.Index;

            if (!baseColors.TryGetValue(colorIndex, out var baseColor))
            {
                ColorSpace baseSpace = BaseSpace;
                IList <PdfDirectObject> components = new List <PdfDirectObject>();
                {
                    int    componentCount      = baseSpace.ComponentCount;
                    int    componentValueIndex = colorIndex * componentCount;
                    byte[] baseComponentValues = BaseComponentValues;
                    for (int componentIndex = 0; componentIndex < componentCount; componentIndex++)
                    {
                        var byteValue = componentValueIndex < baseComponentValues.Length
                            ? baseComponentValues[componentValueIndex]
                            : 0;
                        var value = ((int)byteValue & 0xff) / 255d;
                        components.Add(PdfReal.Get(value));
                        componentValueIndex++;
                    }
                }
                baseColor = baseColors[colorIndex] = baseSpace.GetColor(components, null);
            }
            return(baseColor);
        }
Ejemplo n.º 3
0
        public override Color GetColor(IList <PdfDirectObject> components, IContentContext context)
        {
            //TODO

            Pattern pattern = context.Resources.Patterns[(PdfName)components[components.Count - 1]];

            if (pattern is TilingPattern)
            {
                TilingPattern tilingPattern = (TilingPattern)pattern;
                if (tilingPattern.PaintType == TilingPattern.PaintTypeEnum.Uncolored)
                {
                    ColorSpace underlyingColorSpace = UnderlyingColorSpace;
                    if (underlyingColorSpace == null)
                    {
                        throw new ArgumentException("Uncolored tiling patterns not supported by this color space because no underlying color space has been defined.");
                    }

                    // Get the color to be used for colorizing the uncolored tiling pattern!
                    Color color = underlyingColorSpace.GetColor(components, context);
                    // Colorize the uncolored tiling pattern!
                    pattern = tilingPattern.Colorize(color);
                }
            }
            return(pattern);
        }
Ejemplo n.º 4
0
 public override SKColor GetColor(Color color, double?alfa = null)
 {
     return(BaseSpace.GetColor(GetBaseColor((IndexedColor)color), alfa));
 }