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
C# 如何在WinForms中绘制图像反射?_C#_.net_Winforms_Gdi+ - Fatal编程技术网

C# 如何在WinForms中绘制图像反射?

C# 如何在WinForms中绘制图像反射?,c#,.net,winforms,gdi+,C#,.net,Winforms,Gdi+,我想用C#(WinForms)绘制图像的反射,所以我需要能够水平翻转图像。我知道我可以用image.RotateFlip来实现这一点,但这种方法的问题是,我必须翻转图像两次,这样我才能在下一次绘制时再次将其右侧向上绘制。每幅图像每画两次这样做似乎很慢 我想做翻转时,我画的形象,所以我只需要翻转一次,但我找不到任何方法来做这件事。这可能吗 我考虑过的另一种方法是以某种方式翻转图形对象,正常绘制图像,然后翻转图形对象,以便下一次绘制正确。如果这比翻转图像两次要快,可以这样做吗 另外,我不想在内存中保

我想用C#(WinForms)绘制图像的反射,所以我需要能够水平翻转图像。我知道我可以用image.RotateFlip来实现这一点,但这种方法的问题是,我必须翻转图像两次,这样我才能在下一次绘制时再次将其右侧向上绘制。每幅图像每画两次这样做似乎很慢

我想做翻转时,我画的形象,所以我只需要翻转一次,但我找不到任何方法来做这件事。这可能吗

我考虑过的另一种方法是以某种方式翻转图形对象,正常绘制图像,然后翻转图形对象,以便下一次绘制正确。如果这比翻转图像两次要快,可以这样做吗

另外,我不想在内存中保留2个图像,因此无法复制图像并翻转克隆。

编辑

像这样的吗

     draw(new Bitmap (img).rotateflip(param))
好的,rotateflip不会返回图像

,仅从旋转唇翻转一次就足够了。没有

RotateNoneFlipNone  Specifies no rotation and no flipping.
Rotate90FlipNone    Specifies a 90-degree rotation without flipping.
Rotate180FlipNone   Specifies a 180-degree rotation without flipping.
Rotate270FlipNone   Specifies a 270-degree rotation without flipping.
RotateNoneFlipX Specifies no rotation followed by a horizontal flip.
Rotate90FlipX   Specifies a 90-degree rotation followed by a horizontal flip.
Rotate180FlipX  Specifies a 180-degree rotation followed by a horizontal flip.
Rotate270FlipX  Specifies a 270-degree rotation followed by a horizontal flip.
RotateNoneFlipY Specifies no rotation followed by a vertical flip.
Rotate90FlipY   Specifies a 90-degree rotation followed by a vertical flip.
Rotate180FlipY  Specifies a 180-degree rotation followed by a vertical flip.
Rotate270FlipY  Specifies a 270-degree rotation followed by a vertical flip.
RotateNoneFlipXY    Specifies no rotation followed by a horizontal and vertical flip.
Rotate90FlipXY  Specifies a 90-degree rotation followed by a horizontal and vertical flip.
Rotate180FlipXY Specifies a 180-degree rotation followed by a horizontal and vertical flip.
Rotate270FlipXY Specifies a 270-degree rotation followed by a horizontal and vertical flip.
从中获取此代码,并检查是否有帮助

using System;
using System.Drawing;
using System.Windows.Forms;

class ImageReflection: Form
{
     Image image = Image.FromFile("Color.jpg");

     public static void Main()
     {
          Application.Run(new ImageReflection());
     }
     public ImageReflection()
     {
          ResizeRedraw = true;

     }
     protected override void OnPaint(PaintEventArgs pea)
     {
          DoPage(pea.Graphics, ForeColor,ClientSize.Width, ClientSize.Height);
     }     
     protected void DoPage(Graphics grfx, Color clr, int cx, int cy)
     {
          int cxImage = image.Width;
          int cyImage = image.Height;

          grfx.DrawImage(image, cx / 2, cy / 2,  cxImage,  cyImage);
          grfx.DrawImage(image, cx / 2, cy / 2, -cxImage,  cyImage);
          grfx.DrawImage(image, cx / 2, cy / 2,  cxImage, -cyImage);
          grfx.DrawImage(image, cx / 2, cy / 2, -cxImage, -cyImage);
     }
}

要使用反射绘制图像,我必须(1)将图像向右上绘制,然后(2)翻转图像以绘制反射,然后将其向后翻转,以便下一个绘制步骤(1)将图像向右上绘制。这是因为实际图像实例现在已翻转。这有意义吗?是图像还是位图?对象?它是System.Drawing.Bitmap对象。为什么不在内存中保留两个图像?这似乎是最简单的方法。