情况如下:
我们有一些通用的图形代码,我们用于其中一个项目.在对代码进行一些清理之后,似乎某些东西不再起作用了(图形输出看起来完全错误).
我对提供正确输出的代码的最后一个版本运行了一个diff,看起来我们改变了我们的一个函数,如下所示:
static public Rectangle FitRectangleOld(Rectangle rect, Size targetSize)
{
if (rect.Width <= 0 || rect.Height <= 0)
{
rect.Width = targetSize.Width;
rect.Height = targetSize.Height;
}
else if (targetSize.Width * rect.Height >
rect.Width * targetSize.Height)
{
rect.Width = rect.Width * targetSize.Height / rect.Height;
rect.Height = targetSize.Height;
}
else
{
rect.Height = rect.Height * targetSize.Width / rect.Width;
rect.Width = targetSize.Width;
}
return rect;
}
Run Code Online (Sandbox Code Playgroud)
至
static public Rectangle FitRectangle(Rectangle rect, Size targetSize)
{
if (rect.Width <= 0 || rect.Height <= …Run Code Online (Sandbox Code Playgroud)