Ejemplo n.º 1
0
        /**
         * <summary>Gets the color corresponding to the specified components.</summary>
         * <param name="components">Color components to convert.</param>
         */
        public static DeviceColor Get(PdfArray components)
        {
            if (components == null)
            {
                return(null);
            }
            if (components.Wrapper is DeviceColor wrapped)
            {
                return(wrapped);
            }

            switch (components.Count)
            {
            case 1:
                return(DeviceGrayColor.Get(components));

            case 3:
                return(DeviceRGBColor.Get(components));

            case 4:
                return(DeviceCMYKColor.Get(components));

            default:
                return(null);
            }
        }
Ejemplo n.º 2
0
        public override SKColor GetSKColor(Color color, float?alpha = null)
        {
            DeviceRGBColor spaceColor = (DeviceRGBColor)color;
            var            skColor    = new SKColor(
                (byte)Math.Round(spaceColor.R * 255),
                (byte)Math.Round(spaceColor.G * 255),
                (byte)Math.Round(spaceColor.B * 255));

            if (alpha != null)
            {
                skColor = skColor.WithAlpha((byte)(alpha.Value * 255));
            }
            return(skColor);
        }