|
-
Apr 21st, 2025, 03:23 PM
#1
[twinBASIC] - Simple Animated GIF Player with WinRT / BitmapDecoder & Multi-Threading
I have just translated my previous VB6 GIF Player project to twinBASIC 64-bit and also introduced multi-threading capabilities to take advantage of this feature exclusive to tB. Now each delegate will complete its work on a new thread.
Here is the demo project: GIFPlayerTB.zip (download the test GIFs from the VB6 thread linked above as they were too big to include in the attachment).
-
Jul 22nd, 2025, 04:55 PM
#2
Re: [twinBASIC] - Simple Animated GIF Player with WinRT / BitmapDecoder & Multi-Threa
This is another twist on the animated GIF player above only instead of manually decoding the frames and rendering them individually with a Timer, this time all the nitty-gritty details are abstracted by a XAML Image control hosted inside a regular PictureBox. This makes the code much shorter and cleaner:
Code:
Private WithEvents cImage As cImage, bFlag As Boolean
Private Sub Form_Load()
Set cImage = New cImage
If cImage.InitIsland(picImage.hWnd) Then cImage.LoadImage "https://www.vbforums.com/images/ieimages/2025/03/2.gif": bFlag = Not bFlag
End Sub
Private Sub Form_Click()
cImage.LoadImage IIf(bFlag, "https://media.githubusercontent.com/media/SixLabors/ImageSharp/main/tests/Images/Input/Gif/cheers.gif", "https://www.vbforums.com/images/ieimages/2025/03/2.gif")
bFlag = Not bFlag
End Sub
Private Sub cImage_ImageOpened(imgWidth As Long, imgHeight As Long)
With picImage
.Move .Left, .Top, .ScaleX(imgWidth, vbPixels, .ScaleMode), .ScaleY(imgHeight, vbPixels, .ScaleMode)
End With
End Sub
Private Sub cImage_ImageFailed(sErrorMessage As String)
MsgBox sErrorMessage, vbOKOnly + vbExclamation, App.Title
End Sub
Private Sub picImage_Resize()
With picImage
Width = .Width + (Width - ScaleWidth) + .Left * 2
Height = .Height + (Height - ScaleHeight) + .Top * 2
End With
End Sub
Using the {Binding} markup extension, the Image control's Source property is bound to a Uri object thus enabling it to play GIFs both from a web address or a local file. Additional features include:
- Click on the image to Stop/Start the animation
- Click on the form to switch between two sample GIFs loaded from different URLs
- The control raises events to signal whether the image was opened successfully or failed (to due to an incorrect file format or URL address)
Here is the demo project: GIFPlayerXaml.zip (compile the executable to run the demo)
Requirements: Windows 10 or later!
-
Jul 23rd, 2025, 04:58 PM
#3
Re: [twinBASIC] - Simple Animated GIF Player with WinRT / BitmapDecoder & Multi-Threa
Need pictures or the picture is incomplete.
https://github.com/yereverluvinunclebert
Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.
By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.
-
Jul 23rd, 2025, 05:51 PM
#4
Re: [twinBASIC] - Simple Animated GIF Player with WinRT / BitmapDecoder & Multi-Threa
Give it a whirl if you want the full experience, not much point in taking a picture of an animated GIF!
-
Jul 24th, 2025, 05:20 AM
#5
Re: [twinBASIC] - Simple Animated GIF Player with WinRT / BitmapDecoder & Multi-Threa
https://github.com/yereverluvinunclebert
Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.
By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|