Tiled animated gif image in picturebox
Tiled animated gif image in picturebox
Tiled animated gif image in picturebox
Tiled animated gif image in picturebox
Tiled animated gif image in picturebox
Tiled animated gif image in picturebox Tiled animated gif image in picturebox Tiled animated gif image in picturebox Tiled animated gif image in picturebox Tiled animated gif image in picturebox Tiled animated gif image in picturebox Tiled animated gif image in picturebox Tiled animated gif image in picturebox
Tiled animated gif image in picturebox Tiled animated gif image in picturebox
Tiled animated gif image in picturebox
Go Back  Xtreme Visual Basic Talk > > > Tiled animated gif image in picturebox


Reply
 
Thread Tools Display Modes
  #1  
Old 05-30-2014, 12:10 AM
daluge daluge is offline
Newcomer
 
Join Date: May 2014
Posts: 1
Question Tiled animated gif image in picturebox


I noticed that tiling a .gif image as the BackgroundImage of anything does not support the animation, so I came here to ask how would one make this possible? If you could provide the code that would be fantastic.

Thanks.
Reply With Quote
  #2  
Old 06-06-2014, 01:47 AM
boops boops's Avatar
boops boops boops boops is offline
Centurion
 
Join Date: Dec 2006
Location: Holland and France
Posts: 146
Default

BackgroundImage doesn't animate a GIF anyway -- only the PictureBox.Image does that. But we can get round this using 2 picture boxes, one to play the animated GIF and another to show the tiled background image.

Here's an example. Start with a Form with a picture box (PictureBox1) for showing the tiled image. Don't set the BackgroundImage yet, but set its BackgroundImageLayout to Tile. You can set its Image to whatever you like.

Add a second picture box (PictureBox2) as a "player" for the animated GIF. Set its Image to the animated GIF and its SizeMode to AutoSize.

Add a Timer (Timer1) and set its Interval to 30 or so. The Timer will be used to grab the image from the player, using the DrawToBitmap method. An advantage of DrawToBitmap is that you can hide the source control off-screen or behind another control at runtime while grabbing (but don't use Hide).

Here's the code for the form:

vb.net Code:
Dim tile As Bitmap Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load tile = New Bitmap(PictureBox2.Image.Width, PictureBox2.Image.Height) PictureBox2.Location = New Point(-PictureBox2.Width, -PictureBox2.Height) 'hide PictureBox2 off-screen Timer1.Start() End Sub Private Sub Timer1_Tick(sender As Object, e As System.EventArgs) Handles Timer1.Tick PictureBox2.DrawToBitmap(tile, PictureBox2.ClientRectangle) PictureBox1.BackgroundImage = tile PictureBox1.Refresh() End Sub

This worked for me with animated GIFs (attached below) for both the tiled BackgroundImage and the Image. The world turns against a chorus of dancing mice.
Attached Images
File Type: gif mouse.gif (13.6 KB, 21 views)
File Type: gif world2.gif (41.0 KB, 21 views)
File Type: gif mouseWorld2.gif (635.4 KB, 12 views)

Last edited by boops boops; 06-06-2014 at 02:20 AM.
Reply With Quote
Reply

Tags
animation, gif, graphics, image, picturebox


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Tiled animated gif image in picturebox
Tiled animated gif image in picturebox
Tiled animated gif image in picturebox Tiled animated gif image in picturebox
Tiled animated gif image in picturebox
Tiled animated gif image in picturebox
Tiled animated gif image in picturebox Tiled animated gif image in picturebox Tiled animated gif image in picturebox Tiled animated gif image in picturebox Tiled animated gif image in picturebox Tiled animated gif image in picturebox Tiled animated gif image in picturebox
Tiled animated gif image in picturebox
Tiled animated gif image in picturebox
 
Tiled animated gif image in picturebox
Tiled animated gif image in picturebox
 
-->