gpt4 book ai didi

c# - C#中旋转图片剪切图片

转载 作者:行者123 更新时间:2023-11-30 17:55:04 24 4
gpt4 key购买 nike

<分区>

我正在尝试使用 C# 旋转图片,并使用以下代码:

///create a new empty bitmap to hold rotated image
Bitmap returnBitmap = new Bitmap(newBMP.Width, newBMP.Height);
//make a graphics object from the empty bitmap
Graphics g = Graphics.FromImage(returnBitmap);
//move rotation point to center of image
g.TranslateTransform((float)newBMP.Width / 2, (float)newBMP.Height / 2);
//rotate
g.RotateTransform(-90);
//move image back
g.TranslateTransform(-(float)newBMP.Width / 2, -(float)newBMP.Height / 2);
//draw passed in image onto graphics object
g.DrawImage(newBMP, new Point(0, 0));

newBMP 是我从表单中获取的位图,我正在更改它的大小。然后我想旋转它,但是当我尝试上面的这段代码时,它会剪切图片的顶部和底部。所有这一切之后,我将新照片保存在服务器上。

除了旋转之外一切正常......

有人看到问题了吗?

已解决 我用过这个:C# rotate bitmap 90 degrees

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com