How to mirror an image using array

后端 未结 1 435
难免孤独
难免孤独 2021-01-23 07:09

I need to mirror an image and display it like this:

To display like this:

This is my code so far, I have had no luck:

int Heigh         


        
相关标签:
1条回答
  • 2021-01-23 07:48

    Image.RotateFlip will do the job at lot faster and easier:

    Bitmap bmp1 = (Bitmap)pictureBox1.Image;
    Bitmap bmp2 = new Bitmap(bmp1.Width * 2, bmp1.Height);
    
    using (Graphics G = Graphics.FromImage(bmp2))
    {
        G.DrawImage(bmp1, 0, 0);
        bmp1.RotateFlip(RotateFlipType.RotateNoneFlipX);
        G.DrawImage(bmp1, bmp1.Width, 0);
        pictureBox2.Image = bmp2;
    }
    

    Instead you could use loops similar to yours and Bitmap.GetPixel and Bitmap.SetPixel but that would be really slow:

    TransformedPic.SetPixel(Width - i, j, TransformedPic.GetPixel(i,j));
    

    Going over one half of the width..

    0 讨论(0)
提交回复
热议问题