Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在C#中旋转位图,并以位图结束?_C#_.net_Bitmap_Image Rotation - Fatal编程技术网

如何在C#中旋转位图,并以位图结束?

如何在C#中旋转位图,并以位图结束?,c#,.net,bitmap,image-rotation,C#,.net,Bitmap,Image Rotation,我有一个位图,我需要在C#中旋转任意度数。我需要的结果是一个位图。我在StackOverflow上看到一些问题部分地解决了这个问题。这些问题的结果是在System.Drawing.Graphics对象中绘制并显示在屏幕上的旋转图像。那不是我需要的。我需要旋转图像,并将其放置到位图对象中 Bitmap rotated = new Bitmap(<dimensions>) using(Graphics g = Graphics.FromImage(rotated)) { // Cod

我有一个位图,我需要在C#中旋转任意度数。我需要的结果是一个位图。我在StackOverflow上看到一些问题部分地解决了这个问题。这些问题的结果是在System.Drawing.Graphics对象中绘制并显示在屏幕上的旋转图像。那不是我需要的。我需要旋转图像,并将其放置到位图对象中

Bitmap rotated = new Bitmap(<dimensions>)
using(Graphics g = Graphics.FromImage(rotated))
{
  // Code to draw the rotated image to g goes here
}
我看不到System.Drawing.Graphics拉出底层位图的方法


还有别的办法吗?我还需要最小的双线性插值。

您可以使用相同的步骤,但可以将图形对象链接到新的位图对象,而不是链接到显示器

Bitmap rotated = new Bitmap(<dimensions>)
using(Graphics g = Graphics.FromImage(rotated))
{
  // Code to draw the rotated image to g goes here
}
Bitmap rotated=新位图()
使用(Graphics g=Graphics.FromImage(旋转))
{
//将旋转图像绘制到g的代码如下所示
}
就在我的脑海里:

  • 可以使用现有图像旋转,如:

  • 您需要修改上述代码以获得精确的边界:使用sin/cos/tan进行一些简单的计算,您将找到正确的边界


  • 希望它能起作用:)

    反过来说,从新创建的位图创建一个图形对象。我在3秒钟内发现了这个问题:C#新手,很抱歉这个愚蠢的问题。然后,通过g.drawImageUnscaled修改基础“旋转”图像?而图形正确地处理放置在图形对象上的图像脱离边界的情况?很酷。谢谢