C# 检查翻译后的图像是否包含矩形

C# 检查翻译后的图像是否包含矩形,c#,.net,system.drawing,C#,.net,System.drawing,我需要以用户指定的角度->绘制图像,然后应用平移变换和旋转变换 using (Graphics d = Graphics.FromImage(img)) { { d.TranslateTransform(img.Width / 2, img.Height / 2); d.RotateTransform(anglec); int k = (int)-(bmp.Width / 2); int

我需要以用户指定的角度->绘制图像,然后应用平移变换和旋转变换

using (Graphics d = Graphics.FromImage(img))
   {
                                    {
    d.TranslateTransform(img.Width / 2, img.Height / 2);
    d.RotateTransform(anglec);
    int k = (int)-(bmp.Width / 2);
    int p = (int)-(bmp.Height / 2);
    Rectangle destRect = new Rectangle(k, p, bmp.Width, bmp.Height);
    Rectangle s = new Rectangle(new Point(0, 0), new Size(img.Width, img.Height));
    if (!s.Contains(destRect))
    {
    }
    d.DrawImage(bmp, destRect, 0, 0, bmp.Width, bmp.Height, GraphicsUnit.Pixel);
   }
有时,旋转后的图像末端似乎脱离了主图像。为了检查是否发生这种情况,我尝试使用
Contains
方法来确定矩形是否包含在主图像中。但它总是出错。我认为转换正在进行中。是否有人可以提供建议