当前位置:网站首页>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.Components
https://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 SubIn 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
边栏推荐
- 【兴趣阅读】Adversarial Filtering Modeling on Long-term User Behavior Sequences for Click-Through Rate Pre
- 光模块字母含义及参数简称大全
- [matlab] communication signal modulation general function interpolation function
- 2022 a special equipment related management (elevator) examination questions simulation examination platform operation
- [matlab] matlab simulates digital baseband transmission system - digital baseband transmission system
- Fault analysis | mongodb 5.0 reports an error, and the legal instruction solves it
- [technology development -25]: integration technology of radio and television network, Internet, telecommunication network and power grid
- National vocational college skills competition (secondary vocational group) network security competition questions - Analysis
- Topological sorting and graphical display of critical path
- 企业级日志分析系统ELK(如果事与愿违那一定另有安排)
猜你喜欢

光模块字母含义及参数简称大全

Principle and practice of common defects in RSA encryption application

1480. 一维数组的动态和

Simulink and Arduino serial port communication

LM small programmable controller software (based on CoDeSys) note 22: error 4268/4052

Simulink与Arduino串口通信

ETCD数据库源码分析——初始化总览

模拟小根堆

Just do it with your hands 7 - * project construction details 2 - hook configuration

Headache delayed double deletion
随机推荐
Just do it with your hands 7 - * project construction details 2 - hook configuration
[matlab] communication signal modulation general function - low pass filter
[interested reading] advantageous filtering modeling on long term user behavior sequences for click through rate pre
June 2022 summary
Supplement the JS of a video website to decrypt the video
中科磐云—数据分析与取证数据包flag
2022 t elevator repair operation certificate examination question bank and simulation examination
KMP match string
NTFS security permissions
Redis realizes ranking function
Enterprise level log analysis system elk (if things backfire, there must be other arrangements)
力扣(LeetCode)184. 部门工资最高的员工(2022.07.03)
[paper summary] zero shot semantic segmentation
[matlab] general function of communication signal modulation bandpass filter
如何使用postman实现简单的接口关联【增删改查】
总线的基本概念
cmake
Unity is connected to the weather system
谷歌 Chrome 浏览器将支持选取文字翻译功能
Get the ID of the record just inserted from laravel