VS2010旗舰版VB.NET版本gif动画制作源代码QZQ

Imports System.ComponentModel
Imports System.IO
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Collections.Generic

Imports System.Windows.Forms

Imports gif.Components

Public Class Form1

Private imagesPaths As New List(Of String)
Private currentImageIndex As Integer
Private timer1 As New Timer
Private gifImage As Image
Private sourceImage As Bitmap


Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
    timer1.Interval = 100 ' 调整为 0.15 秒切换一张图片
    AddHandler timer1.Tick, AddressOf Timer1_Tick

    Timer2.Interval = 100 ' 调整为 0.15 秒切换一张图片
    AddHandler Timer2.Tick, AddressOf Timer2_Tick


End Sub

Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
    Dim openFileDialog1 As New OpenFileDialog()
    openFileDialog1.Filter = "图片文件|*.jpg;*.png;*.bmp;*.gif" ' 注意:添加了 *.gif 以允许选择 GIF 图片
    openFileDialog1.Multiselect = True

    If openFileDialog1.ShowDialog() = DialogResult.OK Then
        imagesPaths.Clear()

        For Each filePath As String In openFileDialog1.FileNames
            imagesPaths.Add(filePath)
            ListBoxImages.Items.Add(Path.GetFileName(filePath))
        Next
    End If
End Sub

Private Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
    If imagesPaths.Count > 0 Then
        currentImageIndex = 0
        timer1.Start()
    Else
        MessageBox.Show("请先选择图片")
    End If



End Sub

Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As EventArgs)
    If currentImageIndex < imagesPaths.Count Then
        Dim imagePath = imagesPaths(currentImageIndex)
        Dim image As Image
        If Path.GetExtension(imagePath).ToLower() = ".gif" Then
            image = Image.FromFile(imagePath)
        Else
            image = New Bitmap(imagePath)
            ' 对非 GIF 图片进行缩放以适应 PictureBox
            Dim newWidth As Integer = PictureBox1.Width
            Dim newHeight As Integer = PictureBox1.Height
            Dim newImage As Image = New Bitmap(image, newWidth, newHeight)
            image = newImage
        End If

        PictureBox1.Image = image
        currentImageIndex += 1
    Else
        timer1.Stop()
        currentImageIndex = 0
    End If
End Sub

Private Sub Button4_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
    If imagesPaths.Count > 0 Then
        currentImageIndex = 0
        timer2.Start()
    Else
        MessageBox.Show("请先选择图片")
    End If




gif动画制作:地球自转

🎉精彩不容错过!新文章震撼登场,却因代码不全让人意犹未尽?别担心!我们为你准备了软件截图,让你先睹为快,感受其强大魅力。

✨如果你渴望解锁全部精彩内容,那么强烈建议你下载完整源代码。它将为你打开一扇通往编程新世界的大门,让你深入探索其中的奥秘,挖掘无限潜力。

🔗源代码下载网址:[https://download.csdn.net/download/qq_32257509/89629987]。赶紧行动起来,下载完整源代码,开启你的编程之旅吧!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

EasySoft易软

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值