/// <summary> /// 使用斜率截距快速算法 /// 以全球国家为例:220毫秒 /// </summary> /// <param name="ply"></param> private unsafe void PolygonToPath(ShapePolygon ply) { float kLon = _quickTransformArgs.kLon; float kLat = _quickTransformArgs.kLat; float bLon = _quickTransformArgs.bLon; float bLat = _quickTransformArgs.bLat; int ringCount = ply.Rings.Length; for (int ri = 0; ri < ringCount; ri++) { ShapePoint[] prjPts = ply.Rings[ri].Points; int nCount = prjPts.Length; PointF[] pts = new PointF[nCount]; fixed(PointF *ptr0 = pts) { PointF *ptr = ptr0; for (int i = 0; i < nCount; i++, ptr++) { ptr->X = (float)(kLon * prjPts[i].X + bLon); ptr->Y = (float)(kLat * prjPts[i].Y + bLat); } } _path.AddPolygon(pts); } }
public unsafe void ToBitmap(PointF[] points, byte[] types, Color trueColor, Color emptyColor, Envelope dstEnvelope, Size size, ref Bitmap buffer) { if (points == null || points.Length == 0 || types == null || types.Length == 0 || dstEnvelope == null || size.IsEmpty) { return; } ShapePoint leftUpCoord = dstEnvelope.LeftUpPoint; float resolutionX = (float)dstEnvelope.Width / (float)size.Width; float resolutionY = (float)dstEnvelope.Height / (float)size.Height; float leftUpX = (float)leftUpCoord.X; float leftUpY = (float)leftUpCoord.Y; fixed(PointF *ptrf = points) { PointF *ptr = ptrf; for (int i = 0; i < points.Length; i++) { ptr->X = ((float)ptr->X - leftUpX) / resolutionX; ptr->Y = -((float)ptr->Y - leftUpY) / resolutionY; ptr++; } } using (Graphics g = Graphics.FromImage(buffer)) { using (GraphicsPath pth = new GraphicsPath(points, types)) { using (SolidBrush brush = new SolidBrush(trueColor)) { g.FillPath(brush, pth); } } } }
/// <summary> /// 将基于AOI计算出的等值线还原到全图 /// </summary> /// <param name="contourLines"></param> /// <param name="aoi"></param> private unsafe void OffsetToFull(List <ContourLine> contourLines, int offsetRow, int offsetCol) { if (contourLines == null || contourLines.Count == 0) { return; } int ptCount = 0; foreach (ContourLine cl in contourLines) { if (cl == null || cl.Count == 0) { continue; } ptCount = cl.Count; fixed(PointF *ptr0 = cl.Points) { PointF *ptr = ptr0; for (int i = 0; i < ptCount; i++, ptr++) { ptr->X = ptr->X + offsetCol; ptr->Y = ptr->Y + offsetRow; } } } }
/// <summary> /// Counts the number of counter-clockwise windings that the polygon makes around a given <paramref name="testPoint">point</paramref>. /// </summary> /// <param name="testPoint">The test point.</param> /// <param name="vertices">A pointer to the array of vertices defining the polygon.</param> /// <param name="vertexCount">The number of vertices in the array.</param> /// <returns>The number of CCW windings.</returns> /// <remarks> /// Algorithm as given on <a href="http://softsurfer.com/Archive/algorithm_0103/algorithm_0103.htm">http://softsurfer.com/Archive/algorithm_0103/algorithm_0103.htm</a>. /// </remarks> private static unsafe int CountWindings(PointF testPoint, PointF *vertices, int vertexCount) { int wn = 0; // the winding number counter // loop through all edges of the polygon int point0 = vertexCount - 1; for (int point1 = 0; point1 < vertexCount; point0 = point1, point1++) { // edge from point0 to point1 if (vertices[point0].Y <= testPoint.Y) { // start y <= testPoint.y if (vertices[point1].Y > testPoint.Y) // an upward crossing { if (IsLeft(vertices[point0], vertices[point1], testPoint) > 0) // testPoint left of edge { wn++; // have a valid up intersect } } } else { // start y > testPoint.y (no test needed) if (vertices[point1].Y <= testPoint.Y) // a downward crossing { if (IsLeft(vertices[point0], vertices[point1], testPoint) < 0) // testPoint right of edge { --wn; // have a valid down intersect } } } } return(wn); }
private static unsafe bool CheckIsComplex(PointF *vertices, int vertexCount) { // the line segments immediately preceding and succeeding a given segment are never considered as "intersecting" for (int n = 2; n < vertexCount - 1; n++) { for (int i = 0; i <= n - 2; i++) { PointF intersection; if (Vector.IntersectLineSegments(vertices[n], vertices[n + 1], vertices[i], vertices[i + 1], out intersection)) { return(true); } } } // when checking against the last line segment, skip the first line segment (since they are adjacent) for (int i = 1; i < vertexCount - 2; i++) { PointF intersection; if (Vector.IntersectLineSegments(vertices[vertexCount - 1], vertices[0], vertices[i], vertices[i + 1], out intersection)) { return(true); } } return(false); }
private unsafe void DrawVLabel1Scales(Graphics g, float beginY, float endY, int lineHeight, float span, float resY) { Matrix oldMatrix = g.Transform; float v = 0; PointF pt = new PointF(3 * FONT_MARGIN, 0); GCHandle handle = GCHandle.Alloc(pt, GCHandleType.Pinned); PointF * ptr = (PointF *)handle.AddrOfPinnedObject(); try { do { ptr->Y = beginY + 1; _matrix.Reset(); _matrix.RotateAt(90, *ptr); g.Transform = _matrix; g.DrawString(((int)v).ToString(), _font, _labelBrush, *ptr); v += resY; beginY += span; }while (beginY < endY); } finally { g.Transform = oldMatrix; handle.Free(); } }
unsafe void PointToGlobalSpace(PointF p, PointF *outPoint) { float px = LocalFlipX ? (1 - p.X) : p.X; float py = LocalFlipY ? (1 - p.Y) : p.Y; outPoint->X = ClientRectangle.X + px * ClientRectangle.Width; outPoint->Y = ClientRectangle.Y + py * ClientRectangle.Height; }
private unsafe void DrawContour(IDrawArgs drawArgs, ContourLine cntLine, ContourClass cntClass, ICanvas canvas) { if (!cntClass.IsDisplay) { return; } ICoordinateTransform tran = canvas.CoordTransform; int nCount = cntLine.Count; PointF[] pts = new PointF[nCount]; GCHandle dstHandle = GCHandle.Alloc(pts, GCHandleType.Pinned); GCHandle srcHandle = GCHandle.Alloc(cntLine.Points, GCHandleType.Pinned); try { MemoryCopy(dstHandle.AddrOfPinnedObject(), srcHandle.AddrOfPinnedObject(), nCount << _pointfSize); // nCount * sizeof(PointF) QuickTransform quickTran = drawArgs.QuickTransformArgs; fixed(PointF *ptr0 = pts) { PointF *ptr = ptr0; for (int i = 0; i < nCount; i++, ptr++) { quickTran.Transform(ptr); } } Graphics g = drawArgs.Graphics as Graphics; // if (_isUseCurveRender) { g.DrawCurve(cntClass.Pen, pts, _tension); } else { _grahpicPath.Reset(); _grahpicPath.AddLines(pts); g.DrawPath(cntClass.Pen, _grahpicPath); } // if (_isLabel) { if (_isCheckConflicting) { if (_conflictor.IsConflicted(pts[0], cntClass.LabelBuffer.Size)) { return; } _conflictor.HoldPosition(pts[0], cntClass.LabelBuffer.Size); } g.DrawImageUnscaled(cntClass.LabelBuffer, (int)pts[0].X, (int)pts[0].Y); } } finally { dstHandle.Free(); srcHandle.Free(); } }
unsafe HRESULT IOleControlSite.TransformCoords(Point *pPtlHimetric, PointF *pPtfContainer, XFORMCOORDS dwFlags) { if (pPtlHimetric is null || pPtfContainer is null) { return(HRESULT.E_INVALIDARG); } HRESULT hr = SetupLogPixels(false); if (hr < 0) { return(hr); } if ((dwFlags & XFORMCOORDS.HIMETRICTOCONTAINER) != 0) { if ((dwFlags & XFORMCOORDS.SIZE) != 0) { pPtfContainer->X = (float)host.HM2Pix(pPtlHimetric->X, logPixelsX); pPtfContainer->Y = (float)host.HM2Pix(pPtlHimetric->Y, logPixelsY); } else if ((dwFlags & XFORMCOORDS.POSITION) != 0) { pPtfContainer->X = (float)host.HM2Pix(pPtlHimetric->X, logPixelsX); pPtfContainer->Y = (float)host.HM2Pix(pPtlHimetric->Y, logPixelsY); } else { Debug.WriteLineIf(AxHTraceSwitch.TraceVerbose, "\t dwFlags not supported: " + dwFlags); return(HRESULT.E_INVALIDARG); } } else if ((dwFlags & XFORMCOORDS.CONTAINERTOHIMETRIC) != 0) { if ((dwFlags & XFORMCOORDS.SIZE) != 0) { pPtlHimetric->X = host.Pix2HM((int)pPtfContainer->X, logPixelsX); pPtlHimetric->Y = host.Pix2HM((int)pPtfContainer->Y, logPixelsY); } else if ((dwFlags & XFORMCOORDS.POSITION) != 0) { pPtlHimetric->X = host.Pix2HM((int)pPtfContainer->X, logPixelsX); pPtlHimetric->Y = host.Pix2HM((int)pPtfContainer->Y, logPixelsY); } else { Debug.WriteLineIf(AxHTraceSwitch.TraceVerbose, "\t dwFlags not supported: " + dwFlags); return(HRESULT.E_INVALIDARG); } } else { Debug.WriteLineIf(AxHTraceSwitch.TraceVerbose, "\t dwFlags not supported: " + dwFlags); return(HRESULT.E_INVALIDARG); } return(HRESULT.S_OK); }
internal static partial int GdipWarpPath( #if NET7_0_OR_GREATER [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef path, #if NET7_0_OR_GREATER [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef matrix, PointF *points, int count, float srcX, float srcY, float srcWidth, float srcHeight, WarpMode warpMode, float flatness);
internal static partial int GdipDrawBeziers( #if NET7_0_OR_GREATER [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef graphics, #if NET7_0_OR_GREATER [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef pen, PointF *points, int count);
public unsafe void ToBitmap(Dictionary <ShapePolygon, Color> vectors, Color emptyColor, Envelope dstEnvelope, Size size, ref Bitmap buffer) { if (vectors == null || vectors.Count == 0 || dstEnvelope == null || size.Width == 0 || size.Height == 0 || buffer == null) { return; } ShapePoint leftUpCoord = dstEnvelope.LeftUpPoint; float resolutionX = (float)dstEnvelope.Width / (float)size.Width; float resolutionY = (float)dstEnvelope.Height / (float)size.Height; float leftUpX = (float)leftUpCoord.X; float leftUpY = (float)leftUpCoord.Y; using (Graphics g = Graphics.FromImage(buffer)) { //g.Clear(emptyColor); g.InterpolationMode = InterpolationMode.NearestNeighbor; //g.SmoothingMode = SmoothingMode.HighQuality; foreach (ShapePolygon ply in vectors.Keys) { if (!dstEnvelope.IsInteractived(ply.Envelope)) { continue; } using (GraphicsPath pth = new GraphicsPath()) { ShapeRing[] rings = ply.Rings; foreach (ShapeRing ring in rings) { if (!dstEnvelope.IsInteractived(ring.Envelope)) { continue; } PointF[] pts = new PointF[ring.Points.Length]; fixed(PointF *ptrf = pts) { PointF *ptr = ptrf; ShapePoint[] shpts = ring.Points; foreach (ShapePoint pt in shpts) { ptr->X = ((float)pt.X - leftUpX) / resolutionX; ptr->Y = -((float)pt.Y - leftUpY) / resolutionY; ptr++; } } pth.AddPolygon(pts); } using (SolidBrush brush = new SolidBrush(vectors[ply])) { g.FillPath(brush, pth); } } } } }
public unsafe void Render(object sender, IDrawArgs drawArgs) { if (_canvas == null) { _canvas = sender as ICanvas; _spatialRef = GetSpatialRef(); _coordTransfrom = _canvas.CoordTransform; } Graphics g = drawArgs.Graphics as Graphics; if (_gridLines == null) { bool isOK = ComputeValidGeoRange(); if (!isOK) { return; } ComputeGridLines(_coordTransfrom); } if (_gridLines != null) { GCHandle prjHandle = GCHandle.Alloc(_allPrjPoints, GCHandleType.Pinned); GCHandle screenHandle = GCHandle.Alloc(_allPixelPoints, GCHandleType.Pinned); try { QuickTransform qickTran = _coordTransfrom.QuickTransform; int ptCount = _allPixelPoints.Length; MemoryCopy(screenHandle.AddrOfPinnedObject(), prjHandle.AddrOfPinnedObject(), ptCount * Marshal.SizeOf(typeof(PointF))); fixed(PointF *ptr0 = _allPixelPoints) { PointF *pixPtr = ptr0; for (int i = 0; i < ptCount; i++, pixPtr++) { qickTran.Transform(pixPtr); } } //draw lon lines DrawLines(g, 0, _lonLines); //draw lat lines int end = Math.Min(_lonLines + _latLines, _gridLines.Count); DrawLines(g, _lonLines, end); //label DrawLabel(g, qickTran); } finally { prjHandle.Free(); screenHandle.Free(); } } }
internal static partial int GdipEnumerateMetafileSrcRectDestPoints( #if NET7_0_OR_GREATER [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef graphics, #if NET7_0_OR_GREATER [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef metafile, PointF *destPoints, int count, ref RectangleF srcRect, GraphicsUnit pageUnit, Graphics.EnumerateMetafileProc callback, IntPtr callbackdata, #if NET7_0_OR_GREATER [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef imageattributes);
/// <summary> /// Green's Theorem-derived formula to compute the area of the polygon. /// </summary> private static unsafe double ComputeSimpleArea(PointF *vertices, int vertexCount) { // technically, this formula does work for complex polygons, it's just that we define inside/outside a complex polygon differently. double result = 0; int point0 = vertexCount - 1; for (int point1 = 0; point1 < vertexCount; point0 = point1, point1++) { // ensure each multiplication is carried out to double precision result += (double)vertices[point0].X * vertices[point1].Y - (double)vertices[point1].X * vertices[point0].Y; } return(Math.Abs(result / 2)); }
unsafe void DrawPolyline(PaintEventArgs e, PointF *points, int pointsCount, bool closed) { if (pointsCount > 1) { for (int i = 1; i < pointsCount; ++i) { DrawLine(e, points[i - 1], points[i]); } if (closed && pointsCount > 2) { DrawLine(e, points[pointsCount - 1], points[0]); } } }
unsafe HRESULT Ole32.IOleControlSite.TransformCoords(Point *pPtlHimetric, PointF *pPtfContainer, Ole32.XFORMCOORDS dwFlags) { if (pPtlHimetric == null || pPtfContainer == null) { return(HRESULT.E_INVALIDARG); } if ((dwFlags & Ole32.XFORMCOORDS.HIMETRICTOCONTAINER) != 0) { if ((dwFlags & Ole32.XFORMCOORDS.SIZE) != 0) { pPtfContainer->X = (float)WebBrowserHelper.HM2Pix(pPtlHimetric->X, WebBrowserHelper.LogPixelsX); pPtfContainer->Y = (float)WebBrowserHelper.HM2Pix(pPtlHimetric->Y, WebBrowserHelper.LogPixelsY); } else if ((dwFlags & Ole32.XFORMCOORDS.POSITION) != 0) { pPtfContainer->X = (float)WebBrowserHelper.HM2Pix(pPtlHimetric->X, WebBrowserHelper.LogPixelsX); pPtfContainer->Y = (float)WebBrowserHelper.HM2Pix(pPtlHimetric->Y, WebBrowserHelper.LogPixelsY); } else { return(HRESULT.E_INVALIDARG); } } else if ((dwFlags & Ole32.XFORMCOORDS.CONTAINERTOHIMETRIC) != 0) { if ((dwFlags & Ole32.XFORMCOORDS.SIZE) != 0) { pPtlHimetric->X = WebBrowserHelper.Pix2HM((int)pPtfContainer->X, WebBrowserHelper.LogPixelsX); pPtlHimetric->Y = WebBrowserHelper.Pix2HM((int)pPtfContainer->Y, WebBrowserHelper.LogPixelsY); } else if ((dwFlags & Ole32.XFORMCOORDS.POSITION) != 0) { pPtlHimetric->X = WebBrowserHelper.Pix2HM((int)pPtfContainer->X, WebBrowserHelper.LogPixelsX); pPtlHimetric->Y = WebBrowserHelper.Pix2HM((int)pPtfContainer->Y, WebBrowserHelper.LogPixelsY); } else { return(HRESULT.E_INVALIDARG); } } else { return(HRESULT.E_INVALIDARG); } return(HRESULT.S_OK); }
unsafe void InitalizeFirstSquare(PointF *points) { var globalSide = (float)Math.Min(Width, Height); var localSideX = globalSide / Width; var localSideY = globalSide / Height; float x1 = (1.0f - localSideX) / 2; float x2 = x1 + localSideX; float y1 = (1.0f - localSideY) / 2; float y2 = y1 + localSideY; points[0] = new PointF(x1, y1); points[1] = new PointF(x2, y1); points[2] = new PointF(x2, y2); points[3] = new PointF(x1, y2); }
public unsafe PointF[] GeoCoord2PixelCoord(ShapePoint[] points) { PointF[] ptfs = new PointF[points.Length]; fixed(PointF *ptr = ptfs) { PointF *pt = ptr; for (int i = 0; i < ptfs.Length; i++, pt++) { pt->X = (float)points[i].X; pt->Y = (float)points[i].Y; } } GeoCoord2PixelCoord(ptfs); return(ptfs); }
private unsafe void DrawLines(Graphics g, int beginLine, int endLine) { try { fixed(PointF *ptr0 = _allPixelPoints) { PointF *allPointPtr = ptr0; // int ptCount = 0; allPointPtr = ptr0; PointF[] vertexBuffer = null; int prePointCount = 0; //for (int iLine = beginLine; iLine < endLine - 1; iLine++) for (int iLine = beginLine; iLine < endLine; iLine++) { ptCount = _gridLines[iLine].SegmentCount; if (prePointCount != ptCount) { vertexBuffer = new PointF[ptCount]; prePointCount = ptCount; } fixed(PointF *buffer0 = vertexBuffer) { PointF *buffer = buffer0; allPointPtr = ptr0 + _gridLines[iLine].BeginIndex; for (int iPt = 0; iPt < ptCount; iPt++, buffer++, allPointPtr++) { buffer->X = allPointPtr->X; buffer->Y = allPointPtr->Y; } } // g.DrawCurve(_gridPen, vertexBuffer); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private static unsafe double ComputeComplexArea(RectangleF bounds, PointF *vertices, int vertexCount) { // This algorithm is more computationally expensive and provides a weaker approximation of // the area of an n-polygon when compared with Formula.AreaOfPolygon, although it does // compute the desired area of a self-intersecting polygon. int areaInPixels = 0; for (float r = bounds.Left; r <= bounds.Right; r++) { for (float c = bounds.Top; c <= bounds.Bottom; c++) { if (CountWindings(new PointF(r, c), vertices, vertexCount) != 0) { areaInPixels++; } } } return(areaInPixels); }
private unsafe void method_0(Matrix4D transform) { int length = this.vector4D_0.Length; if (this.pointF_0 == null || this.pointF_0.Length != length) this.pointF_0 = new PointF[length]; fixed(Vector4D *vector4DPtr1 = this.vector4D_0) fixed(PointF * pointFPtr1 = this.pointF_0) { Vector4D *vector4DPtr2 = vector4DPtr1; PointF * pointFPtr2 = pointFPtr1; for (int index = 0; index < length; ++index) { *pointFPtr2 = transform.TransformToPointF(*vector4DPtr2); ++vector4DPtr2; ++pointFPtr2; } } }
private unsafe void Project(ContourLine cntLine, ICanvas canvas) { ICoordinateTransform tran = canvas.CoordTransform; if (tran == null) { return; } int nCount = cntLine.Count; fixed(PointF *ptr0 = cntLine.Points) { PointF *ptr = ptr0; for (int i = 0; i < nCount; i++, ptr++) { tran.Raster2Prj(ptr); } } cntLine.UpdateEnvelope(); }
private unsafe Feature GetFeature(ContourLine cntLine, ICanvas canvas, int OID) { int ptCount = cntLine.Count; ShapePoint[] pts = new ShapePoint[ptCount]; fixed(PointF *ptr0 = cntLine.Points) { PointF *ptr = ptr0; for (int i = 0; i < ptCount; i++, ptr++) { double geoX, geoY; canvas.CoordTransform.Prj2Geo(ptr->X, ptr->Y, out geoX, out geoY); pts[i] = new ShapePoint(geoX, geoY); } } ShapeLineString ring = new ShapeLineString(pts); ShapePolyline ply = new ShapePolyline(new ShapeLineString[] { ring }); Feature fet = new Feature(OID, ply, new string[] { "Contour" }, new string[] { cntLine.ContourValue.ToString() }, null); return(fet); }
private unsafe ContourLine ReadCntLine(BinaryReader br, double contourValue) { ContourLine.ContourEnvelope evp = ReadEnvelope(br); ContourLine cntLine = new ContourLine(contourValue); cntLine.ClassIndex = br.ReadInt32(); int ptCount = br.ReadInt32(); PointF[] pts = new PointF[ptCount]; fixed(PointF *ptr0 = pts) { PointF *ptr = ptr0; for (int i = 0; i < ptCount; i++, ptr++) { ptr->X = br.ReadSingle(); ptr->Y = br.ReadSingle(); } } cntLine.AddPoints(pts); return(cntLine); }
public void UpdateEnvelope() { float minX = float.MaxValue; float minY = float.MaxValue; float maxX = float.MinValue; float maxY = float.MinValue; unsafe { fixed(PointF *ptr0 = this.Points) { PointF *ptr = ptr0; for (int i = 0; i < this.Count; i++, ptr++) { if (ptr->X < minX) { minX = ptr->X; } if (ptr->X > maxX) { maxX = ptr->X; } if (ptr->Y < minY) { minY = ptr->Y; } if (ptr->Y > maxY) { maxY = ptr->Y; } } } } _envelope = new ContourEnvelope(minX, maxX, minY, maxY); }
private unsafe Feature GetFeature(ContourLine cntLine, double resX, double resY, double minX, double maxY, int OID) { int ptCount = cntLine.Count; ShapePoint[] pts = new ShapePoint[ptCount]; fixed(PointF *ptr0 = cntLine.Points) { PointF *ptr = ptr0; for (int i = 0; i < ptCount; i++, ptr++) { ptr->X = (float)(ptr->X * resX + minX); ptr->Y = (float)(maxY - ptr->Y * resY); pts[i] = new ShapePoint(ptr->X, ptr->Y); } } ShapeLineString ring = new ShapeLineString(pts); ShapePolyline ply = new ShapePolyline(new ShapeLineString[] { ring }); Feature fet = new Feature(OID, ply, new string[] { "Contour" }, new string[] { cntLine.ContourValue.ToString() }, null); return(fet); }
public override void Render(Surface src, Surface dst, Rectangle[] rois, int startIndex, int length) { ColorBgra colTransparent = ColorBgra.Transparent; unsafe { int aaSampleCount = quality * quality; PointF *aaPoints = stackalloc PointF[aaSampleCount]; PixelUtils.GetRgssOffsets(aaPoints, aaSampleCount, quality); ColorBgra *samples = stackalloc ColorBgra[aaSampleCount]; TransformData td; for (int n = startIndex; n < startIndex + length; ++n) { Rectangle rect = rois[n]; for (int y = rect.Top; y < rect.Bottom; y++) { ColorBgra *dstPtr = dst.GetPointAddressUnchecked(rect.Left, y); double relativeY = y - this.yCenterOffset; for (int x = rect.Left; x < rect.Right; x++) { double relativeX = x - this.xCenterOffset; int sampleCount = 0; for (int p = 0; p < aaSampleCount; ++p) { td.X = relativeX + aaPoints[p].X; td.Y = relativeY - aaPoints[p].Y; InverseTransform(ref td); float sampleX = (float)(td.X + this.xCenterOffset); float sampleY = (float)(td.Y + this.yCenterOffset); ColorBgra sample = colPrimary; if (IsOnSurface(src, sampleX, sampleY)) { sample = src.GetBilinearSample(sampleX, sampleY); } else { switch (this.edgeBehavior) { case WarpEdgeBehavior.Clamp: sample = src.GetBilinearSampleClamped(sampleX, sampleY); break; case WarpEdgeBehavior.Wrap: sample = src.GetBilinearSampleWrapped(sampleX, sampleY); break; case WarpEdgeBehavior.Reflect: sample = src.GetBilinearSampleClamped( ReflectCoord(sampleX, src.Width), ReflectCoord(sampleY, src.Height)); break; case WarpEdgeBehavior.Primary: sample = colPrimary; break; case WarpEdgeBehavior.Secondary: sample = colSecondary; break; case WarpEdgeBehavior.Transparent: sample = colTransparent; break; case WarpEdgeBehavior.Original: sample = src[x, y]; break; default: break; } } samples[sampleCount] = sample; ++sampleCount; } *dstPtr = ColorBgra.Blend(samples, sampleCount); ++dstPtr; } } } } }
/// <summary> /// Unit test entry point for complex polygon determination algorithm. /// </summary> /// <remarks>These entry points exist to allow specific testing of the unsafe algorithms for buffer overruns.</remarks> internal static unsafe bool TestIsComplex(PointF *vertices, int vertexCount) { return(CheckIsComplex(vertices, vertexCount)); }
/// <summary> /// Unit test entry point for contains computation algorithm. /// </summary> /// <remarks>These entry points exist to allow specific testing of the unsafe algorithms for buffer overruns.</remarks> internal static unsafe bool TestContains(PointF pt, PointF *vertices, int vertexCount) { return(CountWindings(pt, vertices, vertexCount) != 0); }