My requirement is to crop the image after rotation.
Sample: https://github.com/SanthiyaArulsamy/Samples/tree/master/RotationSample
My actual image:
After rotation:
Here, I have rotated the image at 45 degrees. Now I want to crop the highlighted(Red color rectangle)rectangle area only.

Code:
var cropWindowRect = new System.Drawing.RectangleF(100, 100, 500, 500);
var points = new float[8]
{
cropWindowRect.Left, cropWindowRect.Top,
cropWindowRect.Right, cropWindowRect.Top,
cropWindowRect.Right, cropWindowRect.Bottom,
cropWindowRect.Left, cropWindowRect.Bottom
};
this.imageView.SetImageBitmap(GetCroppedBitmap(imageBitmap, points));
this.imageView.SetScaleType(ImageView.ScaleType.FitCenter);
this.imageView.Rotation = 0;
private static Rect GetRect(float[] points, int imagewidth, int imageheight)
{
int left = (int)Math.Round(Math.Max(0, Math.Min(Math.Min(Math.Min(points[0], points[2]), points[4]), points[6])));
int top = (int)Math.Round(Math.Max(0, Math.Min(Math.Min(Math.Min(points[1], points[3]), points[5]), points[7])));
int right = (int)Math.Round(Math.Min(imagewidth, Math.Max(Math.Max(Math.Max(points[0], points[2]), points[4]), points[6])));
int bottom = (int)Math.Round(Math.Min(imageheight, Math.Max(Math.Max(Math.Max(points[1], points[3]), points[5]), points[7])));
return new Rect(left, top, right, bottom);
}
private static Bitmap GetCroppedBitmap(Bitmap bitmap, float[] points)
{
Rect rect = GetRect(points, bitmap.Width, bitmap.Height);
var height = rect.Height();
var width = rect.Width();
if (rect.Height() + rect.Top > bitmap.Height)
height = bitmap.Height - rect.Top;
if (rect.Width() + rect.Left > bitmap.Width)
width = bitmap.Width - rect.Left;
if (width > 0 && height > 0)
return Bitmap.CreateBitmap(bitmap, rect.Left, rect.Top, width, height);
else
return bitmap;
}
Please suggest to me how to find image coordinates points after rotation.

