iTextSharp.text.pdf.PdfShading.SetColorSpace C# (CSharp) Метод

SetColorSpace() защищенный Метод

protected SetColorSpace ( BaseColor color ) : void
color iTextSharp.text.BaseColor
Результат void
        protected void SetColorSpace(BaseColor color)
        {
            cspace = color;
            int type = ExtendedColor.GetType(color);
            PdfObject colorSpace = null;
            switch (type) {
                case ExtendedColor.TYPE_GRAY: {
                    colorSpace = PdfName.DEVICEGRAY;
                    break;
                }
                case ExtendedColor.TYPE_CMYK: {
                    colorSpace = PdfName.DEVICECMYK;
                    break;
                }
                case ExtendedColor.TYPE_SEPARATION: {
                    SpotColor spot = (SpotColor)color;
                    colorDetails = writer.AddSimple(spot.PdfSpotColor);
                    colorSpace = colorDetails.IndirectReference;
                    break;
                }
                case ExtendedColor.TYPE_PATTERN:
                case ExtendedColor.TYPE_SHADING: {
                    ThrowColorSpaceError();
                    break;
                }
                default:
                    colorSpace = PdfName.DEVICERGB;
                    break;
            }
            shading.Put(PdfName.COLORSPACE, colorSpace);
        }

Usage Example

Пример #1
0
        public static PdfShading Type1(PdfWriter writer, BaseColor colorSpace, float[] domain, float[] tMatrix, PdfFunction function)
        {
            PdfShading sp = new PdfShading(writer);

            sp.shading     = new PdfDictionary();
            sp.shadingType = 1;
            sp.shading.Put(PdfName.SHADINGTYPE, new PdfNumber(sp.shadingType));
            sp.SetColorSpace(colorSpace);
            if (domain != null)
            {
                sp.shading.Put(PdfName.DOMAIN, new PdfArray(domain));
            }
            if (tMatrix != null)
            {
                sp.shading.Put(PdfName.MATRIX, new PdfArray(tMatrix));
            }
            sp.shading.Put(PdfName.FUNCTION, function.Reference);
            return(sp);
        }
All Usage Examples Of iTextSharp.text.pdf.PdfShading::SetColorSpace