Esempio n. 1
0
        /// <summary>
        /// Preparations before drawing
        /// </summary>
        void Prepare()
        {
            if (mBuffer == null) 
            NullArgumentException.Publish(typeof(PixelsBuffer), "Buffer");

            #region Initialize rasterizers

            if (mPathGenerator == null) mPathGenerator = new DrawingPathGenerator();

            if (mColorRasterizer == null) mColorRasterizer = new ColorRasterizer();
            mColorRasterizer.Buffer = mBuffer;

            if (mLinearGradientRasterizer == null) mLinearGradientRasterizer = new LinearGradientRasterizer();
            mLinearGradientRasterizer.Buffer = mBuffer;

            if (mRadialGradientRasterizer == null) mRadialGradientRasterizer = new RadialGradientRasterizer();
            mRadialGradientRasterizer.Buffer = mBuffer;

            preparationRequired = false;
            #endregion

            #region Prepare gamma correction
            if (gammaPreparationRequired)
            {
                if (mGammaCorrected)
                {
                    IGammaCorrector corrector = new PowerGammaCorrector(gammaRed, gammaGreen, gammaBlue);
                    mColorRasterizer.Gamma = corrector;
                    mLinearGradientRasterizer.Gamma = corrector;
                    mRadialGradientRasterizer.Gamma = corrector;
                }
                else
                {
                    mColorRasterizer.Gamma = null;
                    mLinearGradientRasterizer.Gamma = null;
                    mRadialGradientRasterizer.Gamma = null;
                }

                gammaPreparationRequired = false;
            }
            #endregion

            #region Prepare opacity masking
            if (opacityPreparationRequired)
            {
                mColorRasterizer.OpacityMask = mOpacityMask;
                mLinearGradientRasterizer.OpacityMask = mOpacityMask;
                mRadialGradientRasterizer.OpacityMask = mOpacityMask;

                opacityPreparationRequired = false;
            }
            #endregion

        }
Esempio n. 2
0
        /// <summary>
        /// Preparations before drawing
        /// </summary>
        void Prepare()
        {
            if (mBuffer == null)
            {
                NullArgumentException.Publish(typeof(PixelsBuffer), "Buffer");
            }

            #region Initialize rasterizers

            if (mPathGenerator == null)
            {
                mPathGenerator = new DrawingPathGenerator();
            }

            if (mColorRasterizer == null)
            {
                mColorRasterizer = new ColorRasterizer();
            }
            mColorRasterizer.Buffer = mBuffer;

            if (mLinearGradientRasterizer == null)
            {
                mLinearGradientRasterizer = new LinearGradientRasterizer();
            }
            mLinearGradientRasterizer.Buffer = mBuffer;

            if (mRadialGradientRasterizer == null)
            {
                mRadialGradientRasterizer = new RadialGradientRasterizer();
            }
            mRadialGradientRasterizer.Buffer = mBuffer;

            preparationRequired = false;
            #endregion

            #region Prepare gamma correction
            if (gammaPreparationRequired)
            {
                if (mGammaCorrected)
                {
                    IGammaCorrector corrector = new PowerGammaCorrector(gammaRed, gammaGreen, gammaBlue);
                    mColorRasterizer.Gamma          = corrector;
                    mLinearGradientRasterizer.Gamma = corrector;
                    mRadialGradientRasterizer.Gamma = corrector;
                }
                else
                {
                    mColorRasterizer.Gamma          = null;
                    mLinearGradientRasterizer.Gamma = null;
                    mRadialGradientRasterizer.Gamma = null;
                }

                gammaPreparationRequired = false;
            }
            #endregion

            #region Prepare opacity masking
            if (opacityPreparationRequired)
            {
                mColorRasterizer.OpacityMask          = mOpacityMask;
                mLinearGradientRasterizer.OpacityMask = mOpacityMask;
                mRadialGradientRasterizer.OpacityMask = mOpacityMask;

                opacityPreparationRequired = false;
            }
            #endregion
        }