public override void Prepare() { base.Prepare(); ISpanInterpolator spanInterpolator = base.Interpolator; _mode0 = (spanInterpolator.GetType() == typeof(SpanInterpolatorLinear) && ((SpanInterpolatorLinear)spanInterpolator).Transformer.GetType() == typeof(VertexProcessing.Affine) && ((VertexProcessing.Affine)((SpanInterpolatorLinear)spanInterpolator).Transformer).IsIdentity()); }
public override void Prepare() { base.Prepare(); ISpanInterpolator spanInterpolator = base.Interpolator; _mode0 = (spanInterpolator.GetType() == typeof(PixelFarm.Agg.Transform.SpanInterpolatorLinear) && ((PixelFarm.Agg.Transform.SpanInterpolatorLinear)spanInterpolator).Transformer.GetType() == typeof(PixelFarm.Agg.Transform.Affine) && ((PixelFarm.Agg.Transform.Affine)((PixelFarm.Agg.Transform.SpanInterpolatorLinear)spanInterpolator).Transformer).IsIdentity()); }
public override void GenerateColors(ColorRGBA[] outputColors, int startIndex, int x, int y, int len) { ISpanInterpolator spanInterpolator = base.Interpolator; int bufferIndex; byte[] srcBuffer = srcRW.GetBuffer(); if (spanInterpolator.GetType() == typeof(PixelFarm.Agg.Transform.SpanInterpolatorLinear) && ((PixelFarm.Agg.Transform.SpanInterpolatorLinear)spanInterpolator).Transformer.GetType() == typeof(PixelFarm.Agg.Transform.Affine) && ((PixelFarm.Agg.Transform.Affine)((PixelFarm.Agg.Transform.SpanInterpolatorLinear)spanInterpolator).Transformer).IsIdentity()) { bufferIndex = srcRW.GetBufferOffsetXY(x, y); //unsafe { #if true do { outputColors[startIndex].blue = (byte)srcBuffer[bufferIndex++]; outputColors[startIndex].green = (byte)srcBuffer[bufferIndex++]; outputColors[startIndex].red = (byte)srcBuffer[bufferIndex++]; outputColors[startIndex].alpha = (byte)srcBuffer[bufferIndex++]; ++startIndex; } while (--len != 0); #else fixed(byte *pSource = &fg_ptr[bufferIndex]) { int *pSourceInt = (int *)pSource; fixed(RGBA_Bytes *pDest = &span[spanIndex]) { int *pDestInt = (int *)pDest; do { *pDestInt++ = *pSourceInt++; } while (--len != 0); } } #endif } return; } spanInterpolator.Begin(x + base.dx, y + base.dy, len); int accColor0, accColor1, accColor2, accColor3; int back_r = m_bgcolor.red; int back_g = m_bgcolor.green; int back_b = m_bgcolor.blue; int back_a = m_bgcolor.alpha; int maxx = srcRW.Width - 1; int maxy = srcRW.Height - 1; srcBuffer = srcRW.GetBuffer(); unchecked { do { int x_hr; int y_hr; spanInterpolator.GetCoord(out x_hr, out y_hr); x_hr -= base.dxInt; y_hr -= base.dyInt; int x_lr = x_hr >> img_subpix_const.SHIFT; int y_lr = y_hr >> img_subpix_const.SHIFT; int weight; if (x_lr >= 0 && y_lr >= 0 && x_lr < maxx && y_lr < maxy) { accColor0 = accColor1 = accColor2 = accColor3 = (int)img_subpix_const.SCALE * (int)img_subpix_const.SCALE / 2; x_hr &= (int)img_subpix_const.MASK; y_hr &= (int)img_subpix_const.MASK; bufferIndex = srcRW.GetBufferOffsetXY(x_lr, y_lr); weight = (((int)img_subpix_const.SCALE - x_hr) * ((int)img_subpix_const.SCALE - y_hr)); if (weight > BASE_MASK) { accColor0 += weight * srcBuffer[bufferIndex + CO.R]; accColor1 += weight * srcBuffer[bufferIndex + CO.G]; accColor2 += weight * srcBuffer[bufferIndex + CO.B]; accColor3 += weight * srcBuffer[bufferIndex + CO.A]; } weight = (x_hr * ((int)img_subpix_const.SCALE - y_hr)); if (weight > BASE_MASK) { bufferIndex += bytesBetweenPixelInclusive; accColor0 += weight * srcBuffer[bufferIndex + CO.R]; accColor1 += weight * srcBuffer[bufferIndex + CO.G]; accColor2 += weight * srcBuffer[bufferIndex + CO.B]; accColor3 += weight * srcBuffer[bufferIndex + CO.A]; } weight = (((int)img_subpix_const.SCALE - x_hr) * y_hr); if (weight > BASE_MASK) { ++y_lr; bufferIndex = srcRW.GetBufferOffsetXY(x_lr, y_lr); accColor0 += weight * srcBuffer[bufferIndex + CO.R]; accColor1 += weight * srcBuffer[bufferIndex + CO.G]; accColor2 += weight * srcBuffer[bufferIndex + CO.B]; accColor3 += weight * srcBuffer[bufferIndex + CO.A]; } weight = (x_hr * y_hr); if (weight > BASE_MASK) { bufferIndex += bytesBetweenPixelInclusive; accColor0 += weight * srcBuffer[bufferIndex + CO.R]; accColor1 += weight * srcBuffer[bufferIndex + CO.G]; accColor2 += weight * srcBuffer[bufferIndex + CO.B]; accColor3 += weight * srcBuffer[bufferIndex + CO.A]; } accColor0 >>= img_subpix_const.SHIFT * 2; accColor1 >>= img_subpix_const.SHIFT * 2; accColor2 >>= img_subpix_const.SHIFT * 2; accColor3 >>= img_subpix_const.SHIFT * 2; } else { if (x_lr < -1 || y_lr < -1 || x_lr > maxx || y_lr > maxy) { accColor0 = back_r; accColor1 = back_g; accColor2 = back_b; accColor3 = back_a; } else { accColor0 = accColor1 = accColor2 = accColor3 = (int)img_subpix_const.SCALE * (int)img_subpix_const.SCALE / 2; x_hr &= (int)img_subpix_const.MASK; y_hr &= (int)img_subpix_const.MASK; weight = (((int)img_subpix_const.SCALE - x_hr) * ((int)img_subpix_const.SCALE - y_hr)); if (weight > BASE_MASK) { } x_lr++; weight = (x_hr * ((int)img_subpix_const.SCALE - y_hr)); if (weight > BASE_MASK) { if ((uint)x_lr <= (uint)maxx && (uint)y_lr <= (uint)maxy) { BlendInFilterPixel(ref accColor0, ref accColor1, ref accColor2, ref accColor3, srcRW.GetBuffer(), srcRW.GetBufferOffsetXY(x_lr, y_lr), weight); } else { accColor0 += back_r * weight; accColor1 += back_g * weight; accColor2 += back_b * weight; accColor3 += back_a * weight; } } x_lr--; y_lr++; weight = (((int)img_subpix_const.SCALE - x_hr) * y_hr); if (weight > BASE_MASK) { if ((uint)x_lr <= (uint)maxx && (uint)y_lr <= (uint)maxy) { BlendInFilterPixel(ref accColor0, ref accColor1, ref accColor2, ref accColor3, srcRW.GetBuffer(), srcRW.GetBufferOffsetXY(x_lr, y_lr), weight); } else { accColor0 += back_r * weight; accColor1 += back_g * weight; accColor2 += back_b * weight; accColor3 += back_a * weight; } } x_lr++; weight = (x_hr * y_hr); if (weight > BASE_MASK) { if ((uint)x_lr <= (uint)maxx && (uint)y_lr <= (uint)maxy) { BlendInFilterPixel(ref accColor0, ref accColor1, ref accColor2, ref accColor3, srcRW.GetBuffer(), srcRW.GetBufferOffsetXY(x_lr, y_lr), weight); } else { accColor0 += back_r * weight; accColor1 += back_g * weight; accColor2 += back_b * weight; accColor3 += back_a * weight; } } accColor0 >>= img_subpix_const.SHIFT * 2; accColor1 >>= img_subpix_const.SHIFT * 2; accColor2 >>= img_subpix_const.SHIFT * 2; accColor3 >>= img_subpix_const.SHIFT * 2; } } outputColors[startIndex].red = (byte)accColor0; outputColors[startIndex].green = (byte)accColor1; outputColors[startIndex].blue = (byte)accColor2; outputColors[startIndex].alpha = (byte)accColor3; ++startIndex; spanInterpolator.Next(); } while (--len != 0); } }