我有以下代码,用System.Drawing.Graphics将上传的图像绘制在150 x 200 div中,但当图像来自IOS设备时,图片会向右旋转90度。
FYI:我在JavaScript画布中绘制图像时也遇到了同样的问题,此解决方案对我有用。因此,我正在寻找一个C#中等效的解决方案。
FYI:我在JavaScript画布中绘制图像时也遇到了同样的问题,此解决方案对我有用。因此,我正在寻找一个C#中等效的解决方案。
private System.Drawing.Image ResizeAndDraw(System.Drawing.Image objTempImage)
{
Size objSize = new Size(150, 200);
Bitmap objBmp;
objBmp = new Bitmap(objSize.Width, objSize.Height);
Graphics g = Graphics.FromImage(objBmp);
g.SmoothingMode = SmoothingMode.HighQuality;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
//Rectangle rect = new Rectangle(x, y, thumbSize.Width, thumbSize.Height);
Rectangle rect = new Rectangle(0,0,150,200);
//g.DrawImage(objTempImage, rect, 0, 0, objTempImage.Width, objTempImage.Height, GraphicsUnit.Pixel);
g.DrawImage(objTempImage, rect);
return objBmp;
}
pItem.Value[0]
可能与Windows不同。在我的代码中,我使用了RuntimeInformation.IsOSPlatform(OSPlatform.Windows)?pItem.Value[0]: pItem.Value.Last()
。 - 我零0七