public static bool IsPointInsideRegion(Bitmap bitmap, System.Drawing.Point P1, System.Drawing.Point P2, System.Drawing.Point P3, System.Drawing.Point P4, System.Drawing.Point Px)
{
try
{
Bitmap bmp = new Bitmap(bitmap.Size.Width, bitmap.Size.Height);
Graphics grph = Graphics.FromImage(bmp);
System.Drawing.Point[] pointsArray = { P1, P2, P3, P4 };
System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
path.AddClosedCurve(pointsArray);
Region pathRegion = new Region(path);
if (pathRegion.IsVisible(Px, grph))
{
return(true);
}
else
{
return(false);
}
}
catch (Exception ex)
{
ex = new Exception("Error occurred while identifying if point lies inside the quadrilateral or not. " + ex.Message);
throw ex;
}
}