当前位置:网站首页>VB. Net GIF (making and disassembling - optimizing code, class library - 5)
VB. Net GIF (making and disassembling - optimizing code, class library - 5)
2022-07-04 05:25:00 【Xiaoyu 163】
I wrote an article before , It's making and disassembling GIF The article , But the code is too complicated , I laughed after reading it
This time in the class library gif Production and disassembly of
First reference dll, Name is :Gif.Components, You can search and download on Baidu download Gif.Componentshttps://dlc2.pconline.com.cn/filedown_1609054_10722470/Bv6pnYGm/pconline1517912109089.rar
Found after downloading x86(32 position ), There are Gif.Components.dll, if necessary x64, Just decompile to get C# Source code , Reuse x64 Schema generation Gif.Components.dll( There's no need )
Create a new class in the class library , It's called :GifMake
Write :
Imports System.Drawing
Imports System.Windows.Forms
Public Class GifMake
Protected Image As Imaging.FrameDimension
Protected bmp As Bitmap
Protected bmp2() As Bitmap
Public AGE As New Gif.Components.AnimatedGifEncoder()
''' <summary>
''' Take apart gif, Please call directly
''' </summary>
''' <param name="gif"> Pass in gif The absolute path to the file </param>
''' <param name="SavePath"> Pass in the absolute path of the folder where the file is saved </param>
''' <param name="SaveName"> Name of the saved file , Don't write , That is, direct transmission ""</param>
''' <param name="SaveStyle"> Save the format of the file : for example .jpg;.png;.bmp</param>
''' <returns>null</returns>
Public Function SplitGif(gif As String, SavePath As String, SaveName As String, SaveStyle As String)
bmp = New Bitmap(gif)
Image = New Imaging.FrameDimension(bmp.FrameDimensionsList(0))
Dim bmp2(bmp.GetFrameCount(Image) - 1)
For i As Integer = 0 To bmp2.Count - 1
bmp.SelectActiveFrame(Image, i)
bmp2(i) = New Bitmap(bmp)
Next
For i As Integer = 0 To bmp2.Count - 1
bmp2(i).Save(SavePath & "\" & SaveName & i & "." & SaveStyle)
Next
Return vbNull
End Function
''' <summary>
''' synthesis GIF
''' </summary>
''' <param name="sleep"> Milliseconds per frame interval </param>
''' <returns>null</returns>
Public Function CraftGif(sleep As Integer)
Dim open As New OpenFileDialog
open.Filter = " Picture file |*.jpg;*.png;*.ico;*.bmp;*.jpeg;*.wmf;*.emf;*.gif"
open.Title = " Select Picture "
open.Multiselect = True
open.ShowDialog()
If IO.File.Exists(open.FileName) = True Then
Dim count As Integer
count = open.FileNames.Count
Dim save As New SaveFileDialog
save.Filter = "GIF file |*.gif"
save.Title = " preservation GIF"
save.ShowDialog()
AGE.Start(save.FileName)
AGE.SetDelay(sleep)
AGE.SetRepeat(0)
Dim i As Integer = 0
While i < count
AGE.AddFrame(Drawing.Image.FromFile(open.FileNames(i)))
Math.Max(Threading.Interlocked.Increment(i), i - 1)
End While
AGE.Finish()
End If
Return vbNull
End Function
End Class
Call on the main form
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
GDIgif.SplitGif("C:\Users\Administrator\Desktop\test.gif", "C:\Users\Administrator\Desktop", "", "jpg")
End Sub
Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
GDIgif.CraftGif(200)
End Sub
In function segment :SplitGif You can modify it yourself , There is no correct way to write here , Can imitate CraftGIF Write in openFileDialog and saveFileDialog To save pictures
It's really much simpler than what I wrote before
边栏推荐
猜你喜欢
[MySQL practice of massive data with high concurrency, high performance and high availability -8] - transaction isolation mechanism of InnoDB
[技术发展-25]:广播电视网、互联网、电信网、电网四网融合技术
VB.net GIF(制作、拆解——优化代码,类库——5)
Flask
KMP match string
c语言经典指针和数组笔试题解析
Simulink and Arduino serial port communication
Supplement the JS of a video website to decrypt the video
C语言简易学生管理系统(含源码)
Customize a pager needed in your project
随机推荐
Flink1.13 basic SQL syntax (II) join operation
Write a complete answer applet (including single choice questions, judgment questions and multiple topics) (III) single choice questions, judgment questions, and the first question display
JS string splicing
LM小型可编程控制器软件(基于CoDeSys)笔记二十一:错误3703
NTFS security permissions
[matlab] matlab simulation - low pass Gaussian white noise
补某视频网站的js,进行视频解密
Analysis of classical pointer and array written test questions in C language
中职组网络安全—内存取证
Principle and practice of common defects in RSA encryption application
[matlab] matlab simulates digital bandpass transmission systems - QPSK and OQPSK systems
With the advent of the IP era, how can E-sports hotels take advantage of the "east wind" of games?
Programming example of stm32f1 and stm32subeide -74hc595 drives 4-bit 7-segment nixie tube
Flask
Zzulioj:1201: mode problem
[QT] timer
1480. 一维数组的动态和
[QT] create mycombobox click event
基于单片机的太阳能杀虫系统
远程桌面客户端 RDP