html制作网页图片自动滑动代码 (c语言怎么实现图片的旋转)

用winimage制作img镜像的5种方法,c语言怎么实现图片的旋转

声明变量与旋转图片:

 private List<Image> imageList;
 private int currentIndex;
 public Form1()
 {
     InitializeComponent();
    
     imageList = new List<Image>();
     currentIndex = 0;
 }
 private void pictureBox2_Click(object sender, EventArgs e)
 {
     if (pictureBox1.Image != null)
     {
         pictureBox1.Image.RotateFlip(RotateFlipType.Rotate90FlipNone);
         pictureBox1.Invalidate(); // 强制控件重绘以显示旋转后的图片
     }
 }

用winimage制作img镜像的5种方法,c语言怎么实现图片的旋转

显示上一张图片事件:

 private void pictureBox4_Click(object sender, EventArgs e)
 {
     if (currentIndex > 0)
     {
         currentIndex--;
         pictureBox1.Image = imageList[currentIndex];
     }
 }

显示下一张图片事件:

private void pictureBox3_Click(object sender, EventArgs e)
{
    if (imageList.Count > 0)
    {
        currentIndex = (currentIndex + 1) % imageList.Count; // 循环显示图片
        pictureBox1.Image = imageList[currentIndex];
    }
}

用winimage制作img镜像的5种方法,c语言怎么实现图片的旋转

打开浏览图片的文件夹:

private void button5_Click(object sender, EventArgs e)
{
    FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
    if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
    {
        string[] files = Directory.GetFiles(folderBrowserDialog.SelectedPath, "*.*", SearchOption.AllDirectories)
                        .Where(s => s.EndsWith(".jpg") || s.EndsWith(".jpeg") || s.EndsWith(".png") || s.EndsWith(".gif") || s.EndsWith(".bmp"))
                        .ToArray();
        foreach (string file in files)
        {
            Image newImage = Image.FromFile(file);
            imageList.Add(newImage);
        }
        if (imageList.Count > 0)
        {
            pictureBox1.Image = imageList[0];
            currentIndex = 0;
        }
    }
}

用winimage制作img镜像的5种方法,c语言怎么实现图片的旋转

浏览图片:

private void button1_Click(object sender, EventArgs e)
{
    OpenFileDialog openFileDialog = new OpenFileDialog();
    if (openFileDialog.ShowDialog() == DialogResult.OK)
    {
        Image newImage = Image.FromFile(openFileDialog.FileName);
        imageList.Add(newImage);
        pictureBox1.Image = newImage;
        currentIndex = imageList.Count - 1;
    }
}

#文章首发挑战赛##头条创作挑战赛##冬日生活打卡季#