예제 #1
0
        /// <summary>
        /// GetColor
        /// </summary>
        public Color GetColor(List <double> values)
        {
            var colorValues       = new List <double>();
            var index             = LimitIndexToBoundaries((int)values[0]);
            var numberColorValues = baseColorSpace.GetNumberOfValuesPerColor();

            if (!useProcedure)
            {
                index *= numberColorValues;

                for (int i = 0; i < numberColorValues; i++)
                {
                    colorValues.Add(hexString[index + i] / 255.0);
                }
            }
            else
            {
                var operandStack = interpreter.OperandStack;

                var intOp = new IntegerOperand(index);
                operandStack.Push(intOp);

                interpreter.Execute(tintTransformationProcedure);

                for (int i = 0; i < numberColorValues; i++)
                {
                    var real = operandStack.PopRealValue();
                    colorValues.Add(real);
                }

                colorValues.Reverse();
            }

            return(baseColorSpace.GetColor(colorValues));
        }
예제 #2
0
        /// <summary>
        /// Prepare dictionaries
        /// </summary>
        private void PrepareStandardDictionaries(int postscriptVersion)
        {
            ResourceManager = new ResourceManager();
            ResourceManager.DefineResource("Category", new NameOperand("Generic"), new DictionaryOperand());

            DictionaryStack = new EpsStack <EpsDictionary>();
            SystemDict      = new EpsDictionary {
                IsPermanent = true
            };
            GlobalDict = new EpsDictionary {
                IsPermanent = true
            };
            UserDict = new EpsDictionary {
                IsPermanent = true
            };
            ErrorDict = new EpsDictionary {
                IsPermanent = true
            };
            DollarErrordict = new EpsDictionary {
                IsPermanent = true
            };
            statusDict = new EpsDictionary {
                IsPermanent = true
            };
            fontDict = new EpsDictionary {
                IsPermanent = true
            };

            DictionaryStack.Push(SystemDict);
            DictionaryStack.Push(GlobalDict);
            DictionaryStack.Push(UserDict);

            var systemDict = SystemDict;

            var     name    = new NameOperand("systemdict");
            Operand operand = new DictionaryOperand(SystemDict);

            systemDict.Add(name, operand);

            name    = new NameOperand("userdict");
            operand = new DictionaryOperand(UserDict);
            systemDict.Add(name, operand);

            name    = new NameOperand("globaldict");
            operand = new DictionaryOperand(GlobalDict);
            systemDict.Add(name, operand);

            name    = new NameOperand("statusdict");
            operand = new DictionaryOperand(statusDict);
            systemDict.Add(name, operand);

            name    = new NameOperand("errordict");
            operand = new DictionaryOperand(ErrorDict);
            systemDict.Add(name, operand);

            name    = new NameOperand("$error");
            operand = new DictionaryOperand(DollarErrordict);
            systemDict.Add(name, operand);

            name    = new NameOperand("GlobalFontDirectory");
            operand = new DictionaryOperand(fontDict);
            systemDict.Add(name, operand);

            name    = new NameOperand("SharedFontDirectory");
            operand = new DictionaryOperand(fontDict);
            systemDict.Add(name, operand);

            name    = new NameOperand("true");
            operand = new BooleanOperand(true);
            systemDict.Add(name, operand);

            name    = new NameOperand("false");
            operand = new BooleanOperand(false);
            systemDict.Add(name, operand);

            name    = new NameOperand("null");
            operand = new NullOperand();
            systemDict.Add(name, operand);

            // for level 1 do not create this name, some adobe scripts
            // assume level 2 or higher just based on the existence of the name

            if (postscriptVersion >= 2)
            {
                name    = new NameOperand("languagelevel");
                operand = new IntegerOperand(postscriptVersion);
                systemDict.Add(name, operand);
            }

            name = new NameOperand("newerror");
            var b = new BooleanOperand(false);

            DollarErrordict.Add(name, b);
        }