Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.6k views
in Technique[技术] by (71.8m points)

How can I make a original picture and its mirrored image merge together to be one image in C#?

The original picture: The original picture

enter image description here

How I want to display it: Original picture with mirrored image

enter image description here

So far, I believe I will need to make a copy of original picture(transformPic) into another variable (lets call it Temp), then resize transformedPic for double width. Copy Temp into transformedPic. Then I will store a mirrored image of the original picture into Temp and copy it into the second half of transformedPic.

My code so far:

int Height = transformedPic.GetLength(0); //rows
                    int Width = transformedPic.GetLength(1); //columns


                    Color Temp;
                    //copying transformedPic into temp variable
                    for (int i = 0; i < Height; i++)
                    {
                        for (int j = 0; j < Width; j++)
                        {
                            Temp = transformedPic[i, j];
                            transformedPic[i, j] = transformedPic[i, j];
                            transformedPic[i, j] = Temp;
                        }
                    }

                    //doubling the width of transformedPic
                    for (int i = 0; i < Height; i++)
                    {
                        for (int j = 0; j < Width*2; j++)
                        {
                            transformedPic[i, j-1] = transformedPic[i, j-1];
                        }
                    }

                    //copying temp into transformedPic variable
                    for (int i = 0; i < Height; i++)
                    {
                        for (int j = 0; j < Width; j++)
                        {
                            Temp = transformedPic[i, j];
                            transformedPic[i, j] = transformedPic[i, j];
                            transformedPic[i, j] = Temp;
                        }
                    }

                    //Mirroring original picture horizontally in Temp variable
                    for (int i = 0; i < Height; i++)
                    {
                        for (int j = 0; j < Width / 2; j++)
                        {
                            Temp = transformedPic[i, j];
                            transformedPic[i, j] = transformedPic[i, Width - 1 - j];
                            transformedPic[i, Width - 1 - j] = Temp;
                        }
                    }

How can I store the Temp array(mirrored original image) into the second half of the transformedPic(original picture) and both of them one picture itself?

I have to do all this with the concepts of copying, resizing, and for looping 2D arrays.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...