Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.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# 组合图像以显示在picturebox中_C#_3d_Picturebox - Fatal编程技术网

C# 组合图像以显示在picturebox中

C# 组合图像以显示在picturebox中,c#,3d,picturebox,C#,3d,Picturebox,在C#Windows窗体中,我希望能够操纵图像,将其显示为3幅图像。操作包括,对于三个轴中的每个轴,我在每个轴上都有一个2D图像。结果将看起来像一个3D图像 例如,如果我有3个位图图像;a、 b和c。然后我想制作一个3D图像,其中x轴有图像a,y轴有图像b,z轴有图像c 像这样: 请帮忙 您必须对图像进行“透视扭曲”。 查看类似问题的答案:您可以使用GDI+扭曲图像a、b和c,然后将新的“3D”图像绘制成新的位图 请阅读以下关于倾斜的链接 倾斜图像并将其绘制到新位图中时,必须确保: a的右上角

在C#Windows窗体中,我希望能够操纵图像,将其显示为3幅图像。操作包括,对于三个轴中的每个轴,我在每个轴上都有一个2D图像。结果将看起来像一个3D图像

例如,如果我有3个位图图像;a、 b和c。然后我想制作一个3D图像,其中x轴有图像a,y轴有图像b,z轴有图像c

像这样:

请帮忙

您必须对图像进行“透视扭曲”。
查看类似问题的答案:

您可以使用GDI+扭曲图像a、b和c,然后将新的“3D”图像绘制成新的位图

请阅读以下关于倾斜的链接

倾斜图像并将其绘制到新位图中时,必须确保:

  • a的右上角=b的左上角
  • a的左下角=c的左下角
  • b的左下角=c的左上角
现在,这是基于图像是正方形的假设,我不确定您(作为开发人员)将如何处理矩形图像(也许您可以拉伸它,直到您自己)。我也使用相同的图像,而不是B和C,但概念应该是相同的

下面是一个用WinForm的OnPaint方法编写的快速示例

    protected override void OnPaint(PaintEventArgs e)
    {
        base.OnPaint(e);

        Bitmap xImage = new Bitmap(@"PATH TO IMAGE");

        Size xImageSize = xImage.Size;
        int Skew = 30;

        using (Bitmap xNewImage = new Bitmap(120, 120)) //Determine your size
        {
            using (Graphics xGraphics = Graphics.FromImage(xNewImage))
            {
                Point[] xPointsA =
                {
                    new Point(0, Skew), //Upper Left
                    new Point(xImageSize.Width, 0), //Upper Right
                    new Point(0, xImageSize.Height + Skew) //Lower left
                };
                Point[] xPointsB =
                {
                    new Point(xImageSize.Width, 0), //Upper Left
                    new Point(xImageSize.Width*2, Skew), //Upper Right
                    new Point(xImageSize.Width, xImageSize.Height) //Lower left
                };
                Point[] xPointsC =
                {
                    new Point(xImageSize.Width, xImageSize.Height), //Upper Left
                    new Point(xImageSize.Width*2, xImageSize.Height + Skew), //Upper Right
                    new Point(0, xImageSize.Height + Skew) //Lower left
                };

                //Draw to new Image
                xGraphics.DrawImage(xImage, xPointsA);
                xGraphics.DrawImage(xImage, xPointsB);
                xGraphics.DrawImage(xImage, xPointsC);
            }
            e.Graphics.DrawImage(xNewImage, new Point()); //Here you would want to assign the new image to the picture box
        }
    }