public unsafe override void Render(Surface dst, System.Drawing.Point offset) { if (OwnerList.ScaleFactor < new ScaleFactor(2, 1)) { return; } int[] d2SLookupX = OwnerList.Dst2SrcLookupX; int[] d2SLookupY = OwnerList.Dst2SrcLookupY; int[] s2DLookupX = OwnerList.Src2DstLookupX; int[] s2DLookupY = OwnerList.Src2DstLookupY; ColorBgra[] blackAndWhite = new ColorBgra[2] { ColorBgra.White, ColorBgra.Black }; // draw horizontal lines int sTop = d2SLookupY[offset.Y]; int sBottom = d2SLookupY[offset.Y + dst.Height]; for (int srcY = sTop; srcY <= sBottom; ++srcY) { int dstY = s2DLookupY[srcY]; int dstRow = dstY - offset.Y; if (dst.IsRowVisible(dstRow)) { ColorBgra *dstRowPtr = dst.GetRowAddress(dstRow); ColorBgra *dstRowEndPtr = dstRowPtr + dst.Width; dstRowPtr += offset.X & 1; while (dstRowPtr < dstRowEndPtr) { *dstRowPtr = ColorBgra.Black; dstRowPtr += 2; } } } // draw vertical lines int sLeft = d2SLookupX[offset.X]; int sRight = d2SLookupX[offset.X + dst.Width]; for (int srcX = sLeft; srcX <= sRight; ++srcX) { int dstX = s2DLookupX[srcX]; int dstCol = dstX - offset.X; if (dst.IsColumnVisible(dstX - offset.X)) { byte *dstColPtr = (byte *)dst.GetPointAddress(dstCol, 0); byte *dstColEndPtr = dstColPtr + dst.Stride * dst.Height; dstColPtr += (offset.Y & 1) * dst.Stride; while (dstColPtr < dstColEndPtr) { *((ColorBgra *)dstColPtr) = ColorBgra.Black; dstColPtr += 2 * dst.Stride; } } } }
private void DrawToGraphics(Graphics g) { ColorBgra colorSolid = ColorBgra.FromColor(this.ForeColor); ColorBgra colorGuide = ColorBgra.FromColor(this.ForeColor); ColorBgra colorGrid = ColorBgra.FromColor(this.ForeColor); colorGrid.A = 128; colorGuide.A = 96; Pen penSolid = new Pen(colorSolid.ToColor(), 1); Pen penGrid = new Pen(colorGrid.ToColor(), 1); Pen penGuide = new Pen(colorGuide.ToColor(), 1); penGrid.DashStyle = DashStyle.Dash; g.Clear(this.BackColor); g.SmoothingMode = SmoothingMode.AntiAlias; Rectangle ourRect = ClientRectangle; ourRect.Inflate(-1, -1); if (lastMouseXY.Y >= 0) { g.DrawLine(penGuide, 0, lastMouseXY.Y, Width, lastMouseXY.Y); } if (lastMouseXY.X >= 0) { g.DrawLine(penGuide, lastMouseXY.X, 0, lastMouseXY.X, Height); } for (float f = 0.25f; f <= 0.75f; f += 0.25f) { float x = Utility.Lerp(ourRect.Left, ourRect.Right, f); float y = Utility.Lerp(ourRect.Top, ourRect.Bottom, f); g.DrawLine(penGrid, Point.Round(new PointF(x, ourRect.Top)), Point.Round(new PointF(x, ourRect.Bottom))); g.DrawLine(penGrid, Point.Round(new PointF(ourRect.Left, y)), Point.Round(new PointF(ourRect.Right, y))); } g.DrawLine(penGrid, ourRect.Left, ourRect.Bottom, ourRect.Right, ourRect.Top); float width = this.ClientRectangle.Width; float height = this.ClientRectangle.Height; for (int c = 0; c < channels; ++c) { SortedList <int, int> channelControlPoints = controlPoints[c]; int points = channelControlPoints.Count; ColorBgra color = GetVisualColor(c); ColorBgra colorSelected = ColorBgra.Blend(color, ColorBgra.White, 128); const float penWidthNonSelected = 1; const float penWidthSelected = 2; float penWidth = mask[c] ? penWidthSelected : penWidthNonSelected; Pen penSelected = new Pen(color.ToColor(), penWidth); color.A = 128; Pen pen = new Pen(color.ToColor(), penWidth); Brush brush = new SolidBrush(color.ToColor()); SolidBrush brushSelected = new SolidBrush(Color.White); SplineInterpolator interpolator = new SplineInterpolator(); IList <int> xa = channelControlPoints.Keys; IList <int> ya = channelControlPoints.Values; PointF[] line = new PointF[Entries]; for (int i = 0; i < points; ++i) { interpolator.Add(xa[i], ya[i]); } for (int i = 0; i < line.Length; ++i) { line[i].X = (float)i * (width - 1) / (entries - 1); line[i].Y = (float)(Utility.Clamp(entries - 1 - interpolator.Interpolate(i), 0, entries - 1)) * (height - 1) / (entries - 1); } pen.LineJoin = LineJoin.Round; g.DrawLines(pen, line); for (int i = 0; i < points; ++i) { int k = channelControlPoints.Keys[i]; float x = k * (width - 1) / (entries - 1); float y = (entries - 1 - channelControlPoints.Values[i]) * (height - 1) / (entries - 1); const float radiusSelected = 4; const float radiusNotSelected = 3; const float radiusUnMasked = 2; bool selected = (mask[c] && pointsNearMousePerChannel[c] == i); float size = selected ? radiusSelected : (mask[c] ? radiusNotSelected : radiusUnMasked); RectangleF rect = Utility.RectangleFromCenter(new PointF(x, y), size); g.FillEllipse(selected ? brushSelected : brush, rect.X, rect.Y, rect.Width, rect.Height); g.DrawEllipse(selected ? penSelected : pen, rect.X, rect.Y, rect.Width, rect.Height); } pen.Dispose(); } penSolid.Dispose(); penGrid.Dispose(); penGuide.Dispose(); }
public Level(ColorBgra in_lo, ColorBgra in_hi, float[] gamma, ColorBgra out_lo, ColorBgra out_hi) { colorInLow = in_lo; colorInHigh = in_hi; colorOutLow = out_lo; colorOutHigh = out_hi; if (gamma.Length != 3) { throw new ArgumentException("gamma", "gamma must be a float[3]"); } this.gamma = gamma; UpdateLookupTable(); }
public Constant(ColorBgra setColor) { this.setColor = setColor; }
public override ColorBgra Apply(ColorBgra color) { return(ColorBgra.FromBgra(CurveB[color.B], CurveG[color.G], CurveR[color.R], color.A)); }
public override ColorBgra Apply(ColorBgra color) { return(setColor); }
public override ColorBgra Apply(ColorBgra color) { byte average = (byte)(((int)color.R + (int)color.G + (int)color.B) / 3); return(ColorBgra.FromBgra(average, average, average, color.A)); }
public override ColorBgra Apply(ColorBgra color) { byte i = color.GetIntensityByte(); return(ColorBgra.FromBgra(i, i, i, color.A)); }
public override ColorBgra Apply(ColorBgra color) { return(ColorBgra.FromBgra((byte)(255 - color.B), (byte)(255 - color.G), (byte)(255 - color.R), (byte)(255 - color.A))); }
public override ColorBgra Apply(ColorBgra color) { return(ColorBgra.FromUInt32(color.Bgra | 0xff000000)); }
public override ColorBgra Apply(ColorBgra color) { return(ColorBgra.FromUInt32((color.Bgra & 0x00ffffff) + addValue)); }
public override ColorBgra Apply(ColorBgra color) { color[channel] = setValue; return(color); }
public BlendConstant(ColorBgra blendColor) { this.blendColor = blendColor; }