Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Add-Type -AssemblyName PresentationCore
- Add-Type -AssemblyName system.drawing
- [void][reflection.assembly]::LoadWithPartialName("System.Windows.Forms")
- $delay = 35
- $filename = "animation.gif"
- $fileStream = New-Object System.IO.FileStream $filename, 'Create'
- $gif = New-Object -TypeName System.Windows.Media.Imaging.GifBitmapEncoder
- foreach ($frame in Get-ChildItem ".\*.bmp") {
- $bmp = [System.Drawing.Bitmap]::FromFile($frame.fullname)
- $hbmp = $bmp.GetHbitMap()
- $bmpsrc = [System.Windows.Interop.Imaging]::CreateBitmapSourceFromHBitmap($hbmp, [System.IntPtr]::Zero, 'Empty', [System.Windows.Media.Imaging.BitmapSizeOptions]::FromEmptyOptions())
- For ($i = 0; $i -lt $delay; $i++) {
- $gif.Frames.Add([System.Windows.Media.Imaging.BitmapFrame]::Create($bmpsrc))
- }
- $hbmp = $bmp = $null
- }
- $gif.Save($fileStream)
- $fileStream.Flush()
- $fileStream.Dispose()
- $bytes = [System.IO.File]::ReadAllBytes("animation.gif")
- $applicationExtension = [byte[]](33, 255, 11, 78, 69, 84, 83, 67, 65, 80, 69, 50, 46, 48, 3, 1, 0, 0, 0)
- $newBytes = New-Object -TypeName 'System.Collections.Generic.List[byte]'
- $newBytes.AddRange([byte[]]$bytes[0..12]);
- $newBytes.AddRange($applicationExtension);
- $newBytes.AddRange([byte[]]$bytes[13..($bytes.count)])
- $streamE = New-Object System.IO.MemoryStream(,$newBytes)
- $wpImage = [System.Drawing.Image]::FromStream($streamE)
- #$wpImage.Save("animation-with-delay.gif", "gif") #Save gif with the new delay
- [System.Windows.Forms.Application]::EnableVisualStyles();
- $form = new-object Windows.Forms.Form
- $form.Width = $wpImage.Size.Width;
- $form.Height = $wpImage.Size.Height;
- $form.TopMost = $false
- $form.FormBorderStyle = [System.Windows.Forms.BorderStyle]::None;
- $Form.ControlBox = $False
- $pictureBox = new-object Windows.Forms.PictureBox
- $pictureBox.Width = $wpImage.Size.Width;
- $pictureBox.Height = $wpImage.Size.Height;
- $pictureBox.Image = $wpImage;
- $form.controls.add($pictureBox)
- $form.Add_Shown( { $form.Activate() } )
- $form.ShowDialog()| Out-Null
Advertisement