/// <summary> /// Preparations before drawing /// </summary> void Prepare() { if (mBuffer == null) { NullArgumentException.Publish(typeof(MaskBuffer), "Buffer"); } if (mMaskRasterizer == null) { mMaskRasterizer = new MaskRasterizer(); } //throw new Exception("How to use the mask rasterizer correctly ?"); mMaskRasterizer.ResultMask = mBuffer; preparationRequired = false; }
/// <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 }