我从文件夹中获取图像并将其绘制在白色 btimap 上,如下面的代码所示
Image newImage = new Bitmap(whitesize, whitesize);
using (Graphics graphicsHandle = Graphics.FromImage(newImage))
{
graphicsHandle.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphicsHandle.FillRectangle(System.Drawing.Brushes.White,0,0,whiteHeight,whiteHeight);
graphicsHandle.CompositingMode = CompositingMode.SourceOver;
graphicsHandle.DrawImage(image, whiteHeight, 0, newWidth, newHeight);
}
whiteHeight
是正方形的宽度和高度
将 whiteHeight 除以 2 是行不通的,因为newWidth
和newHeight
是动态的,这更像是一个数学问题