示例#1
0
        internal void SelectBrush(TPdfStream DataStream, PathGradientBrush aBrush, RectangleF Rect, RectangleF RotatedCoords, PointF CenterPoint, string DrawingMatrix)
        {
            ColorBlend cb = null;

            try
            {
                cb = aBrush.InterpolationColors;
            }
            catch (ArgumentException)//Awful way to tell if it has InterpolationColors, but the framework does not give us a choice.
            {
            }

            if (cb == null || cb.Colors.Length == 1)
            {
                cb = GetColorBlendWithoutInterpolationColors(aBrush.Blend, aBrush.SurroundColors[0], aBrush.CenterColor);
            }

            int n = cb.Colors.Length - 1;

            if (cb.Colors[0].A != 255 || cb.Colors[n].A != 255)
            {
                ColorBlend TransparencyBlend = new ColorBlend(2);
                TransparencyBlend.Colors[0]    = ColorUtil.FromArgb(cb.Colors[0].A, cb.Colors[0].A, cb.Colors[0].A);
                TransparencyBlend.Positions[0] = 0;
                TransparencyBlend.Colors[1]    = ColorUtil.FromArgb(cb.Colors[n].A, cb.Colors[n].A, cb.Colors[n].A);
                TransparencyBlend.Positions[1] = 1;
                TPdfGradient SMask = Resources.GetGradient(TGradientType.Radial, TransparencyBlend, Rect, aBrush.CenterPoint, RotatedCoords, DrawingMatrix);
                SelectTransparency(DataStream, 255, TPdfToken.CommandSetAlphaBrush, SMask.GetSMask(), PdfConv.ToRectangleXY(Rect, true));
            }

            Resources.SelectGradient(DataStream, TGradientType.Radial, cb, Rect, CenterPoint, RotatedCoords, DrawingMatrix);
        }
示例#2
0
        internal void SelectBrush(TPdfStream DataStream, LinearGradientBrush aBrush, RectangleF Rect, RectangleF RotatedCoords, string DrawingMatrix)
        {
#if (WPF)
            ColorBlend cb = aBrush.GradientStops;
#else
            ColorBlend cb = null;
            try
            {
                if (aBrush.Blend == null)
                {
                    cb = aBrush.InterpolationColors;                       //if it has interpolationcolors, blend must be null.
                }
            }
            catch (ArgumentException) //Awful way to tell if it has Interpolationcolors, but the framework does not give us a choice.
            {
            }

            if (cb == null)
            {
                cb = GetColorBlendWithoutInterpolationColors(aBrush.Blend, aBrush.LinearColors[0], aBrush.LinearColors[1]);
            }
#endif

            int n = cb.Colors.Length - 1;
            if (cb.Colors[0].A != 255 || cb.Colors[n].A != 255)
            {
                ColorBlend TransparencyBlend = new ColorBlend(2);
                TransparencyBlend.Colors[0]    = ColorUtil.FromArgb(cb.Colors[0].A, cb.Colors[0].A, cb.Colors[0].A);
                TransparencyBlend.Positions[0] = 0;
                TransparencyBlend.Colors[1]    = ColorUtil.FromArgb(cb.Colors[n].A, cb.Colors[n].A, cb.Colors[n].A);
                TransparencyBlend.Positions[1] = 1;
                TPdfGradient SMask = Resources.GetGradient(TGradientType.Axial, TransparencyBlend, Rect, Rect.Location, RotatedCoords, DrawingMatrix);
                SelectTransparency(DataStream, 255, TPdfToken.CommandSetAlphaBrush, SMask.GetSMask(), PdfConv.ToRectangleXY(Rect, true));
            }
            Resources.SelectGradient(DataStream, TGradientType.Axial, cb, Rect, Rect.Location, RotatedCoords, DrawingMatrix);
        }