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

Categories

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

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

The original picture: The original picture

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

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?

question from:https://stackoverflow.com/questions/65848217/how-can-i-make-a-original-picture-and-its-mirrored-image-merge-together-to-be-on

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

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...