private void Render(Surface dst, Surface src, Rectangle rect) { ColorBgra currentPixel; for (int y = rect.Top; y < rect.Bottom; y++) { if (IsCancelRequested) { return; } for (int x = rect.Left; x < rect.Right; x++) { if ((horLoops > 1 || verLoops > 1) && !puzzleRect.Contains(x, y)) { currentPixel = src[x, y]; currentPixel.A = 0; // Delete pixels outside the puzzle border } else if (transparent) { currentPixel = src[x, y]; currentPixel.A = Int32Util.ClampToByte(byte.MaxValue - puzzleSurface[x, y].A); } else { currentPixel = normalOp.Apply(src[x, y], puzzleSurface[x, y]); } dst[x, y] = currentPixel; } } }
void Render(Surface dst, Surface src, Rectangle rect) { Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); ColorBgra sourcePixel, puzzlePixel, finalPixel; for (int y = rect.Top; y < rect.Bottom; y++) { if (IsCancelRequested) { return; } for (int x = rect.Left; x < rect.Right; x++) { int offsetX = (int)(x + selection.Width * Amount5.First / 2); int offsetY = (int)(y + selection.Height * Amount5.Second / 2); puzzlePixel = GetBilinearSampleMirrored(puzzleSurface, offsetX - selection.Left, offsetY - selection.Top); sourcePixel = src[x, y]; if (Amount3) { sourcePixel.A = Int32Util.ClampToByte(255 - puzzlePixel.A); finalPixel = sourcePixel; } else { finalPixel = normalOp.Apply(sourcePixel, puzzlePixel); } dst[x, y] = finalPixel; } } }
private void Render(Surface dst, Surface src, Rectangle rect) { if (blur != 0) { // Call the Gaussian Blur function blurEffect.Render(new Rectangle[] { rect }, 0, 1); } else { dst.CopySurface(shadowSurface, rect.Location, rect); } Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); Rectangle shadowRect = Rectangle.FromLTRB( selection.Left + margin + offsetX, selection.Top + margin + offsetY, selection.Right - margin + offsetX, selection.Bottom - margin + offsetY); ColorBgra shadowPixel; for (int y = rect.Top; y < rect.Bottom; y++) { if (IsCancelRequested) { return; } for (int x = rect.Left; x < rect.Right; x++) { shadowPixel = dst[x, y]; shadowPixel.A = shadowRect.Contains(x, y) ? Int32Util.ClampToByte(shadowPixel.A * color.A / byte.MaxValue) : byte.MinValue; dst[x, y] = normalOp.Apply(src[x, y], shadowPixel); } } }
public static Color ToGdipColor(this ColorRgba128Float color, MidpointRounding roundingMode = 1) { byte red = Int32Util.ClampToByte((int)Math.Round((double)(color.r * 255.0), roundingMode)); byte green = Int32Util.ClampToByte((int)Math.Round((double)(color.g * 255.0), roundingMode)); byte blue = Int32Util.ClampToByte((int)Math.Round((double)(color.b * 255.0), roundingMode)); return(Color.FromArgb(Int32Util.ClampToByte((int)Math.Round((double)(color.a * 255.0), roundingMode)), red, green, blue)); }
private static ColorMap ComputeColorMap(double redGain, double greenGain, double blueGain) { var redMap = new byte[256]; var greenMap = new byte[256]; var blueMap = new byte[256]; for (var i = 0; i < 256; i++) { redMap[i] = Int32Util.ClampToByte((int)Math.Round(i * redGain)); greenMap[i] = Int32Util.ClampToByte((int)Math.Round(i * greenGain)); blueMap[i] = Int32Util.ClampToByte((int)Math.Round(i * blueGain)); } return(new ColorMap(redMap, greenMap, blueMap)); }
private void Render(Surface dst, Surface src, Rectangle rect) { ColorBgra CurrentPixel = this.backColor; for (int y = rect.Top; y < rect.Bottom; y++) { if (IsCancelRequested) { return; } for (int x = rect.Left; x < rect.Right; x++) { CurrentPixel.A = Int32Util.ClampToByte(byte.MaxValue - this.textSurface[x, y].A); dst[x, y] = CurrentPixel; } } }
private void Render(Surface dst, Surface src, Rectangle rect) { ColorBgra currentPixel; for (int y = rect.Top; y < rect.Bottom; y++) { if (IsCancelRequested) { return; } for (int x = rect.Left; x < rect.Right; x++) { currentPixel = (customColor) ? color : src[x, y]; currentPixel.A = Int32Util.ClampToByte(cloudSurface[x, y].A + src[x, y].A - byte.MaxValue); dst[x, y] = currentPixel; } } }
protected override unsafe void OnRenderContent(ISurface <ColorBgra> dstContent, PointInt32 renderOffset) { SizeInt32 num = dstContent.Size <ColorBgra>(); ColorBgra fillColor = base.Changes.FillColor; this.sampleSource.Render(dstContent, renderOffset); for (int i = 0; i < num.Height; i++) { ColorBgra *rowPointer = (ColorBgra *)dstContent.GetRowPointer <ColorBgra>(i); for (int j = 0; j < num.Width; j++) { ColorBgra bgra2 = rowPointer[j]; byte b = Int32Util.ClampToByte(bgra2.B + (fillColor.B - this.basisColor.B)); byte g = Int32Util.ClampToByte(bgra2.G + (fillColor.G - this.basisColor.G)); byte r = Int32Util.ClampToByte(bgra2.R + (fillColor.R - this.basisColor.R)); byte a = Int32Util.ClampToByte(bgra2.A + (fillColor.A - this.basisColor.A)); rowPointer[j] = ColorBgra.FromBgra(b, g, r, a); } } }
public static byte ConvertToByte(this double d) { return(Int32Util.ClampToByte((int)Math.Round(d * byte.MaxValue))); }
private void DrawToDrawingContext(IDrawingContext dc) { RectInt32 rect = base.ClientRectangle.ToRectInt32(); dc.Clear(new ColorRgba128Float?(this.BackColor)); using (dc.UseTranslateTransform(0.5f, 0.5f, MatrixMultiplyOrder.Append)) { using (dc.UseAntialiasMode(AntialiasMode.PerPrimitive)) { RectInt32 num2 = RectInt32.Inflate(rect, -2, -2); int num3 = Math.Min(num2.Width, num2.Height); PointInt32 center = new PointInt32(num2.X + (num3 / 2), num2.Y + (num3 / 2)); double radius = ((double)num3) / 2.0; double scale = ((double)num3) / 3.0; double num7 = ((double)num3) / 2.0; double d = -MathUtil.DegreesToRadians(this.angle); double num9 = Math.Cos(d); double num10 = Math.Sin(d); double rx = (this.rollAmount * Math.Cos(MathUtil.DegreesToRadians(this.rollDirection))) / 90.0; double num12 = (this.rollAmount * Math.Sin(MathUtil.DegreesToRadians(this.rollDirection))) / 90.0; double num13 = rx / (((num12 * num12) < 0.99) ? Math.Sqrt(1.0 - (num12 * num12)) : 1.0); double num14 = num12 / (((rx * rx) < 0.99) ? Math.Sqrt(1.0 - (rx * rx)) : 1.0); double thickness = (this.mouseEntered && !this.onSphere) ? 2.0 : 1.0; if (this.ringOuterEllipseGeometry == null) { this.ringOuterEllipseGeometry = new EllipseGeometry(); } if (this.ringInnerEllipseGeometry == null) { this.ringInnerEllipseGeometry = new EllipseGeometry(); } if (this.ringFillGeometry == null) { this.ringFillGeometry = new CombinedGeometry(GeometryCombineMode.Exclude, this.ringOuterEllipseGeometry, this.ringInnerEllipseGeometry); } this.ringOuterEllipseGeometry.Center = center; this.ringOuterEllipseGeometry.RadiusX = radius - 0.5; this.ringOuterEllipseGeometry.RadiusY = radius - 0.5; this.ringInnerEllipseGeometry.Center = center; this.ringInnerEllipseGeometry.RadiusX = radius; this.ringInnerEllipseGeometry.RadiusY = radius; dc.FillGeometry(this.ringFillGeometry, ringFillBrush, null); if (this.ringOutlinePen == null) { this.ringOutlinePen = new PaintDotNet.UI.Media.Pen(); } this.ringOutlinePen.Brush = ringOutlineBrush; this.ringOutlinePen.Thickness = thickness; dc.DrawCircle(center, radius, this.ringOutlinePen); double num16 = (this.mouseEntered && !this.onSphere) ? ((double)2) : ((double)1); dc.DrawLine(center.X + (scale * num9), center.Y + (scale * num10), center.X + (num7 * num9), center.Y + (num7 * num10), thetaLineBrush, num16); using (dc.UseTranslateTransform((float)center.X, (float)center.Y, MatrixMultiplyOrder.Prepend)) { double num17 = (this.angle * 3.1415926535897931) / 180.0; float num18 = (this.mouseEntered && this.onSphere) ? 1.5f : 1f; int num19 = 0x18; for (int i = 0; i >= (-num19 / 2); i--) { double num22 = (i * 3.1415926535897931) / ((double)num19); double num23 = -num17 - 3.1415926535897931; double xs = Math.Cos(num23) * Math.Cos(num22); double ys = Math.Sin(num23) * Math.Cos(num22); double zs = Math.Sin(num22); double num30 = ((double)(i + (num19 / 2))) / ((double)(num19 / 2)); byte index = Int32Util.ClampToByte((int)(num30 * 255.0)); if (this.latBrushCache[index] == null) { ColorBgra bgra = ColorBgra.Blend(latGradStart, latGradEnd, index); this.latBrushCache[index] = SolidColorBrushCache.Get((ColorRgba128Float)bgra); } SolidColorBrush brush = this.latBrushCache[index]; for (int k = -num19 * 6; k <= (num19 * 6); k++) { num23 = -num17 + ((k * 3.1415926535897931) / ((double)(num19 * 6))); double num33 = Math.Cos(num22); double num34 = Math.Sin(num22); double xe = Math.Cos(num23) * Math.Cos(num22); double ye = Math.Sin(num23) * Math.Cos(num22); double ze = Math.Sin(num22); double num35 = (this.mouseEntered && this.onSphere) ? 1.5 : 1.0; this.Draw3DLine(dc, rx, -num12, scale, xs, ys, zs, xe, ye, ze, brush, num35); xs = xe; ys = ye; zs = ze; } } int num20 = 4; for (int j = -num20; j < num20; j++) { double num37 = -num17 + ((j * 3.1415926535897931) / ((double)num20)); double num38 = -1.5707963267948966; double num39 = Math.Cos(num37) * Math.Cos(num38); double num40 = Math.Sin(num37) * Math.Cos(num38); double num41 = Math.Sin(num38); for (int m = -num20 * 4; m <= 0; m++) { num38 = (m * 3.1415926535897931) / ((double)(num20 * 8)); double num42 = Math.Cos(num37) * Math.Cos(num38); double num43 = Math.Sin(num37) * Math.Cos(num38); double num44 = Math.Sin(num38); double num46 = (this.mouseEntered && this.onSphere) ? 2.0 : 1.0; this.Draw3DLine(dc, rx, -num12, scale, num39, num40, num41, num42, num43, num44, lightBrush, num46); num39 = num42; num40 = num43; num41 = num44; } } } dc.DrawCircle(center, scale, ringInlineBrush, thickness); } } }