public override unsafe void Render( EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, System.Drawing.Rectangle[] rois, int startIndex, int length) { // First we blur the source, and write the result to the destination surface // Then we apply Brightness/Contrast with the input as the dst, and the output as the dst // Third, we apply the Screen blend operation so that dst = dst OVER src ThreeAmountsConfigToken token = (ThreeAmountsConfigToken)parameters; AmountEffectConfigToken blurToken = new AmountEffectConfigToken(token.Amount1); this.blurEffect.Render(blurToken, dstArgs, srcArgs, rois, startIndex, length); BrightnessAndContrastAdjustmentConfigToken bcToken = new BrightnessAndContrastAdjustmentConfigToken(token.Amount2, token.Amount3); this.bcAdjustment.Render(bcToken, dstArgs, dstArgs, rois, startIndex, length); for (int i = startIndex; i < startIndex + length; ++i) { Rectangle roi = rois[i]; for (int y = roi.Top; y < roi.Bottom; ++y) { ColorBgra *dstPtr = dstArgs.Surface.GetPointAddressUnchecked(roi.Left, y); ColorBgra *srcPtr = srcArgs.Surface.GetPointAddressUnchecked(roi.Left, y); screenBlendOp.Apply(dstPtr, srcPtr, dstPtr, roi.Width); } } }
public BrightnessAndContrastAdjustmentConfigToken(BrightnessAndContrastAdjustmentConfigToken copyMe) : base(copyMe) { copyMe.Calculate(); this.calcContrast = copyMe.calcContrast; this.calcBrightness = copyMe.calcBrightness; this.multiply = copyMe.multiply; this.divide = copyMe.divide; this.rgbTable = copyMe.rgbTable; }
public unsafe override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length) { BrightnessAndContrastAdjustmentConfigToken token = (BrightnessAndContrastAdjustmentConfigToken)parameters; int contrast = token.Contrast; int brightness = token.Brightness; int multiply = token.Multiply; int divide = token.Divide; byte[] rgbTable = token.RgbTable; for (int r = startIndex; r < startIndex + length; ++r) { Rectangle rect = rois[r]; for (int y = rect.Top; y < rect.Bottom; ++y) { ColorBgra *srcRowPtr = srcArgs.Surface.GetPointAddress(rect.Left, y); ColorBgra *dstRowPtr = dstArgs.Surface.GetPointAddress(rect.Left, y); ColorBgra *dstRowEndPtr = dstRowPtr + rect.Width; if (divide == 0) { while (dstRowPtr < dstRowEndPtr) { ColorBgra col = *srcRowPtr; int i = col.GetIntensityByte(); uint c = rgbTable[i]; dstRowPtr->Bgra = (col.Bgra & 0xff000000) | c | (c << 8) | (c << 16); ++dstRowPtr; ++srcRowPtr; } } else { while (dstRowPtr < dstRowEndPtr) { ColorBgra col = *srcRowPtr; int i = col.GetIntensityByte(); int shiftIndex = i * 256; col.R = rgbTable[shiftIndex + col.R]; col.G = rgbTable[shiftIndex + col.G]; col.B = rgbTable[shiftIndex + col.B]; *dstRowPtr = col; ++dstRowPtr; ++srcRowPtr; } } } } return; }
protected override void InitialInitToken() { theEffectToken = new BrightnessAndContrastAdjustmentConfigToken(0, 0); }
public unsafe override void Render( EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, System.Drawing.Rectangle[] rois, int startIndex, int length) { // First we blur the source, and write the result to the destination surface // Then we apply Brightness/Contrast with the input as the dst, and the output as the dst // Third, we apply the Screen blend operation so that dst = dst OVER src ThreeAmountsConfigToken token = (ThreeAmountsConfigToken)parameters; AmountEffectConfigToken blurToken = new AmountEffectConfigToken(token.Amount1); this.blurEffect.Render(blurToken, dstArgs, srcArgs, rois, startIndex, length); BrightnessAndContrastAdjustmentConfigToken bcToken = new BrightnessAndContrastAdjustmentConfigToken(token.Amount2, token.Amount3); this.bcAdjustment.Render(bcToken, dstArgs, dstArgs, rois, startIndex, length); for (int i = startIndex; i < startIndex + length; ++i) { Rectangle roi = rois[i]; for (int y = roi.Top; y < roi.Bottom; ++y) { ColorBgra* dstPtr = dstArgs.Surface.GetPointAddressUnchecked(roi.Left, y); ColorBgra* srcPtr = srcArgs.Surface.GetPointAddressUnchecked(roi.Left, y); screenBlendOp.Apply(dstPtr, srcPtr, dstPtr, roi.Width); } } }