OVH Cloud OVH Cloud

animation Gif

4 réponses
Avatar
Olivier Bonneau
Bonjour,

comment stoper l'animation d'un gif animé ?

merci,
olivier.
--
-----------------------
il y a 10 sortent de personnes, celle qui comprennent le binaire et les
autres ...
-----------------------
Toutes mes fautes d'ortographes sont volontaires ! ;-)

4 réponses

Avatar
David Bouchard
Voici un poste que j'avais répondu plus bas. >>>>


Voici deux section de code que tu pourrais trouvé très intéressante sur les
gifs animés, ceci fonctionne très bien.

Crée toi deux formulaires et remplace le contenu de chacun par une des
sections de code. La première te permet de comprendre comment dessiner un
gif animé et la seconde comment choisir le frame du gif que tu désire
dessiner.

David

Public Class Form1

Inherits System.Windows.Forms.Form

#Region " Code généré par le Concepteur Windows Form "

Public Sub New()

MyBase.New()

'Cet appel est requis par le Concepteur Windows Form.

InitializeComponent()

MyInitializeComponent()

'Ajoutez une initialisation quelconque après l'appel InitializeComponent()

End Sub

'La méthode substituée Dispose du formulaire pour nettoyer la liste des
composants.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

'Requis par le Concepteur Windows Form

Private components As System.ComponentModel.IContainer

'REMARQUE : la procédure suivante est requise par le Concepteur Windows Form

'Elle peut être modifiée en utilisant le Concepteur Windows Form.

'Ne la modifiez pas en utilisant l'éditeur de code.

Friend WithEvents Button1 As System.Windows.Forms.Button

Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

Me.Button1 = New System.Windows.Forms.Button

Me.PictureBox1 = New System.Windows.Forms.PictureBox

Me.SuspendLayout()

'

'Button1

'

Me.Button1.Location = New System.Drawing.Point(16, 8)

Me.Button1.Name = "Button1"

Me.Button1.TabIndex = 0

Me.Button1.Text = "Button1"

'

'PictureBox1

'

Me.PictureBox1.Location = New System.Drawing.Point(24, 80)

Me.PictureBox1.Name = "PictureBox1"

Me.PictureBox1.Size = New System.Drawing.Size(192, 160)

Me.PictureBox1.TabIndex = 1

Me.PictureBox1.TabStop = False

'

'Form1

'

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

Me.ClientSize = New System.Drawing.Size(400, 266)

Me.Controls.Add(Me.PictureBox1)

Me.Controls.Add(Me.Button1)

Me.Name = "Form1"

Me.Text = "Form1"

Me.ResumeLayout(False)

End Sub

#End Region



Private _bAnimated As Boolean

Private _Bitmap As Bitmap

Private Sub MyInitializeComponent()

_Bitmap = New Bitmap("C:feu_camp3.gif")

ToogleAnimation()

End Sub

Private Sub ToogleAnimation()

If Not ImageAnimator.CanAnimate(_Bitmap) Then Exit Sub

If _bAnimated Then

ImageAnimator.StopAnimate(_Bitmap, New EventHandler(AddressOf
Me.OnFrameChanged))

Else

ImageAnimator.Animate(_Bitmap, New EventHandler(AddressOf
Me.OnFrameChanged))

End If

_bAnimated = Not _bAnimated

End Sub

Private Sub OnFrameChanged(ByVal sender As Object, ByVal e As EventArgs)

Me.PictureBox1.Invalidate()

End Sub

Private Sub picAff_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint

ImageAnimator.UpdateFrames()

e.Graphics.DrawImage(_Bitmap, New Point(0, 0))

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

If _bAnimated Then

Me.Button1.Text = "&Start"

Else

Me.Button1.Text = "&Stop"

End If

ToogleAnimation()

End Sub

End Class









Public Class Form2

Inherits System.Windows.Forms.Form

#Region " Code généré par le Concepteur Windows Form "

Public Sub New()

MyBase.New()

'Cet appel est requis par le Concepteur Windows Form.

InitializeComponent()

'Ajoutez une initialisation quelconque après l'appel InitializeComponent()

End Sub

'La méthode substituée Dispose du formulaire pour nettoyer la liste des
composants.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

'Requis par le Concepteur Windows Form

Private components As System.ComponentModel.IContainer

'REMARQUE : la procédure suivante est requise par le Concepteur Windows Form

'Elle peut être modifiée en utilisant le Concepteur Windows Form.

'Ne la modifiez pas en utilisant l'éditeur de code.

Friend WithEvents VScrollBar1 As System.Windows.Forms.VScrollBar

Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

Me.VScrollBar1 = New System.Windows.Forms.VScrollBar

Me.PictureBox1 = New System.Windows.Forms.PictureBox

Me.SuspendLayout()

'

'VScrollBar1

'

Me.VScrollBar1.LargeChange = 1

Me.VScrollBar1.Location = New System.Drawing.Point(256, 32)

Me.VScrollBar1.Name = "VScrollBar1"

Me.VScrollBar1.Size = New System.Drawing.Size(17, 208)

Me.VScrollBar1.TabIndex = 3

'

'PictureBox1

'

Me.PictureBox1.Location = New System.Drawing.Point(16, 40)

Me.PictureBox1.Name = "PictureBox1"

Me.PictureBox1.Size = New System.Drawing.Size(224, 200)

Me.PictureBox1.TabIndex = 4

Me.PictureBox1.TabStop = False

'

'Form2

'

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

Me.ClientSize = New System.Drawing.Size(292, 266)

Me.Controls.Add(Me.PictureBox1)

Me.Controls.Add(Me.VScrollBar1)

Me.Name = "Form2"

Me.Text = "Form2"

Me.ResumeLayout(False)

End Sub

#End Region

Private oB As New Bitmap("C:feu_camp3.gif")

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles MyBase.Load

Dim oFD As New
System.Drawing.Imaging.FrameDimension(oB.FrameDimensionsList(0))

Me.VScrollBar1.Maximum = oB.GetFrameCount(oFD) - 1

End Sub



Private Sub pic2_Paint(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint

Dim oFD As New
System.Drawing.Imaging.FrameDimension(oB.FrameDimensionsList(0))

oB.SelectActiveFrame(oFD, Me.VScrollBar1.Value)

e.Graphics.DrawImage(oB, 0, 0)

End Sub

Private Sub VScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.ScrollEventArgs) Handles VScrollBar1.Scroll

Me.PictureBox1.Invalidate()

End Sub

End Class


"Olivier Bonneau" a écrit dans le
message de news:
Bonjour,

comment stoper l'animation d'un gif animé ?

merci,
olivier.
--
-----------------------
il y a 10 sortent de personnes, celle qui comprennent le binaire et les
autres ...
-----------------------
Toutes mes fautes d'ortographes sont volontaires ! ;-)


Avatar
c2i-Richard Clark [MVP]
Merci de citer vos sources d'inspiration !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

http://www.c2i.fr/code.aspx?IDCode97

--
Richard Clark
http://www.c2i.fr - Le portail .NET
[Microsoft MVP .NET]
______________________________________________
Etudiants, lycéens, partez au Japon et gagnez $8000
http://www.project-hoshimi.fr
______________________________________________

"David Bouchard" wrote in message
news:
Voici un poste que j'avais répondu plus bas. >>>>


Voici deux section de code que tu pourrais trouvé très intéressante sur


les
gifs animés, ceci fonctionne très bien.

Crée toi deux formulaires et remplace le contenu de chacun par une des
sections de code. La première te permet de comprendre comment dessiner un
gif animé et la seconde comment choisir le frame du gif que tu désire
dessiner.

David

Public Class Form1

Inherits System.Windows.Forms.Form

#Region " Code généré par le Concepteur Windows Form "

Public Sub New()

MyBase.New()

'Cet appel est requis par le Concepteur Windows Form.

InitializeComponent()

MyInitializeComponent()

'Ajoutez une initialisation quelconque après l'appel InitializeComponent()

End Sub

'La méthode substituée Dispose du formulaire pour nettoyer la liste des
composants.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

'Requis par le Concepteur Windows Form

Private components As System.ComponentModel.IContainer

'REMARQUE : la procédure suivante est requise par le Concepteur Windows


Form

'Elle peut être modifiée en utilisant le Concepteur Windows Form.

'Ne la modifiez pas en utilisant l'éditeur de code.

Friend WithEvents Button1 As System.Windows.Forms.Button

Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox

<System.Diagnostics.DebuggerStepThrough()> Private Sub


InitializeComponent()

Me.Button1 = New System.Windows.Forms.Button

Me.PictureBox1 = New System.Windows.Forms.PictureBox

Me.SuspendLayout()

'

'Button1

'

Me.Button1.Location = New System.Drawing.Point(16, 8)

Me.Button1.Name = "Button1"

Me.Button1.TabIndex = 0

Me.Button1.Text = "Button1"

'

'PictureBox1

'

Me.PictureBox1.Location = New System.Drawing.Point(24, 80)

Me.PictureBox1.Name = "PictureBox1"

Me.PictureBox1.Size = New System.Drawing.Size(192, 160)

Me.PictureBox1.TabIndex = 1

Me.PictureBox1.TabStop = False

'

'Form1

'

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

Me.ClientSize = New System.Drawing.Size(400, 266)

Me.Controls.Add(Me.PictureBox1)

Me.Controls.Add(Me.Button1)

Me.Name = "Form1"

Me.Text = "Form1"

Me.ResumeLayout(False)

End Sub

#End Region



Private _bAnimated As Boolean

Private _Bitmap As Bitmap

Private Sub MyInitializeComponent()

_Bitmap = New Bitmap("C:feu_camp3.gif")

ToogleAnimation()

End Sub

Private Sub ToogleAnimation()

If Not ImageAnimator.CanAnimate(_Bitmap) Then Exit Sub

If _bAnimated Then

ImageAnimator.StopAnimate(_Bitmap, New EventHandler(AddressOf
Me.OnFrameChanged))

Else

ImageAnimator.Animate(_Bitmap, New EventHandler(AddressOf
Me.OnFrameChanged))

End If

_bAnimated = Not _bAnimated

End Sub

Private Sub OnFrameChanged(ByVal sender As Object, ByVal e As EventArgs)

Me.PictureBox1.Invalidate()

End Sub

Private Sub picAff_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint

ImageAnimator.UpdateFrames()

e.Graphics.DrawImage(_Bitmap, New Point(0, 0))

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

If _bAnimated Then

Me.Button1.Text = "&Start"

Else

Me.Button1.Text = "&Stop"

End If

ToogleAnimation()

End Sub

End Class









Public Class Form2

Inherits System.Windows.Forms.Form

#Region " Code généré par le Concepteur Windows Form "

Public Sub New()

MyBase.New()

'Cet appel est requis par le Concepteur Windows Form.

InitializeComponent()

'Ajoutez une initialisation quelconque après l'appel InitializeComponent()

End Sub

'La méthode substituée Dispose du formulaire pour nettoyer la liste des
composants.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

'Requis par le Concepteur Windows Form

Private components As System.ComponentModel.IContainer

'REMARQUE : la procédure suivante est requise par le Concepteur Windows


Form

'Elle peut être modifiée en utilisant le Concepteur Windows Form.

'Ne la modifiez pas en utilisant l'éditeur de code.

Friend WithEvents VScrollBar1 As System.Windows.Forms.VScrollBar

Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox

<System.Diagnostics.DebuggerStepThrough()> Private Sub


InitializeComponent()

Me.VScrollBar1 = New System.Windows.Forms.VScrollBar

Me.PictureBox1 = New System.Windows.Forms.PictureBox

Me.SuspendLayout()

'

'VScrollBar1

'

Me.VScrollBar1.LargeChange = 1

Me.VScrollBar1.Location = New System.Drawing.Point(256, 32)

Me.VScrollBar1.Name = "VScrollBar1"

Me.VScrollBar1.Size = New System.Drawing.Size(17, 208)

Me.VScrollBar1.TabIndex = 3

'

'PictureBox1

'

Me.PictureBox1.Location = New System.Drawing.Point(16, 40)

Me.PictureBox1.Name = "PictureBox1"

Me.PictureBox1.Size = New System.Drawing.Size(224, 200)

Me.PictureBox1.TabIndex = 4

Me.PictureBox1.TabStop = False

'

'Form2

'

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

Me.ClientSize = New System.Drawing.Size(292, 266)

Me.Controls.Add(Me.PictureBox1)

Me.Controls.Add(Me.VScrollBar1)

Me.Name = "Form2"

Me.Text = "Form2"

Me.ResumeLayout(False)

End Sub

#End Region

Private oB As New Bitmap("C:feu_camp3.gif")

Private Sub Form1_Load(ByVal sender As Object, ByVal e As


System.EventArgs)
Handles MyBase.Load

Dim oFD As New
System.Drawing.Imaging.FrameDimension(oB.FrameDimensionsList(0))

Me.VScrollBar1.Maximum = oB.GetFrameCount(oFD) - 1

End Sub



Private Sub pic2_Paint(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint

Dim oFD As New
System.Drawing.Imaging.FrameDimension(oB.FrameDimensionsList(0))

oB.SelectActiveFrame(oFD, Me.VScrollBar1.Value)

e.Graphics.DrawImage(oB, 0, 0)

End Sub

Private Sub VScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.ScrollEventArgs) Handles VScrollBar1.Scroll

Me.PictureBox1.Invalidate()

End Sub

End Class


"Olivier Bonneau" a écrit dans


le
message de news:
> Bonjour,
>
> comment stoper l'animation d'un gif animé ?
>
> merci,
> olivier.
> --
> -----------------------
> il y a 10 sortent de personnes, celle qui comprennent le binaire et les
> autres ...
> -----------------------
> Toutes mes fautes d'ortographes sont volontaires ! ;-)




Avatar
TocToc
MDR, ca casse un homme ca :)
-----Message d'origine-----
Merci de citer vos sources


d'inspiration !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

http://www.c2i.fr/code.aspx?IDCode97

--
Richard Clark
http://www.c2i.fr - Le portail .NET
[Microsoft MVP .NET]
______________________________________________
Etudiants, lycéens, partez au Japon et gagnez $8000
http://www.project-hoshimi.fr
______________________________________________

"David Bouchard" wrote in


message
news:
Voici un poste que j'avais répondu plus bas. >>>>


Voici deux section de code que tu pourrais trouvé très




intéressante sur
les
gifs animés, ceci fonctionne très bien.

Crée toi deux formulaires et remplace le contenu de




chacun par une des
sections de code. La première te permet de comprendre




comment dessiner un
gif animé et la seconde comment choisir le frame du gif




que tu désire
dessiner.

David

Public Class Form1

Inherits System.Windows.Forms.Form

#Region " Code généré par le Concepteur Windows Form "

Public Sub New()

MyBase.New()

'Cet appel est requis par le Concepteur Windows Form.

InitializeComponent()

MyInitializeComponent()

'Ajoutez une initialisation quelconque après l'appel




InitializeComponent()

End Sub

'La méthode substituée Dispose du formulaire pour




nettoyer la liste des
composants.

Protected Overloads Overrides Sub Dispose(ByVal




disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

'Requis par le Concepteur Windows Form

Private components As System.ComponentModel.IContainer

'REMARQUE : la procédure suivante est requise par le




Concepteur Windows
Form

'Elle peut être modifiée en utilisant le Concepteur




Windows Form.

'Ne la modifiez pas en utilisant l'éditeur de code.

Friend WithEvents Button1 As System.Windows.Forms.Button

Friend WithEvents PictureBox1 As




System.Windows.Forms.PictureBox

<System.Diagnostics.DebuggerStepThrough()> Private Sub


InitializeComponent()

Me.Button1 = New System.Windows.Forms.Button

Me.PictureBox1 = New System.Windows.Forms.PictureBox

Me.SuspendLayout()

'

'Button1

'

Me.Button1.Location = New System.Drawing.Point(16, 8)

Me.Button1.Name = "Button1"

Me.Button1.TabIndex = 0

Me.Button1.Text = "Button1"

'

'PictureBox1

'

Me.PictureBox1.Location = New System.Drawing.Point(24,




80)

Me.PictureBox1.Name = "PictureBox1"

Me.PictureBox1.Size = New System.Drawing.Size(192, 160)

Me.PictureBox1.TabIndex = 1

Me.PictureBox1.TabStop = False

'

'Form1

'

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

Me.ClientSize = New System.Drawing.Size(400, 266)

Me.Controls.Add(Me.PictureBox1)

Me.Controls.Add(Me.Button1)

Me.Name = "Form1"

Me.Text = "Form1"

Me.ResumeLayout(False)

End Sub

#End Region



Private _bAnimated As Boolean

Private _Bitmap As Bitmap

Private Sub MyInitializeComponent()

_Bitmap = New Bitmap("C:feu_camp3.gif")

ToogleAnimation()

End Sub

Private Sub ToogleAnimation()

If Not ImageAnimator.CanAnimate(_Bitmap) Then Exit Sub

If _bAnimated Then

ImageAnimator.StopAnimate(_Bitmap, New EventHandler




(AddressOf
Me.OnFrameChanged))

Else

ImageAnimator.Animate(_Bitmap, New EventHandler




(AddressOf
Me.OnFrameChanged))

End If

_bAnimated = Not _bAnimated

End Sub

Private Sub OnFrameChanged(ByVal sender As Object,




ByVal e As EventArgs)

Me.PictureBox1.Invalidate()

End Sub

Private Sub picAff_Paint(ByVal sender As Object, ByVal




e As
System.Windows.Forms.PaintEventArgs) Handles




PictureBox1.Paint

ImageAnimator.UpdateFrames()

e.Graphics.DrawImage(_Bitmap, New Point(0, 0))

End Sub

Private Sub Button1_Click(ByVal sender As




System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

If _bAnimated Then

Me.Button1.Text = "&Start"

Else

Me.Button1.Text = "&Stop"

End If

ToogleAnimation()

End Sub

End Class









Public Class Form2

Inherits System.Windows.Forms.Form

#Region " Code généré par le Concepteur Windows Form "

Public Sub New()

MyBase.New()

'Cet appel est requis par le Concepteur Windows Form.

InitializeComponent()

'Ajoutez une initialisation quelconque après l'appel




InitializeComponent()

End Sub

'La méthode substituée Dispose du formulaire pour




nettoyer la liste des
composants.

Protected Overloads Overrides Sub Dispose(ByVal




disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

'Requis par le Concepteur Windows Form

Private components As System.ComponentModel.IContainer

'REMARQUE : la procédure suivante est requise par le




Concepteur Windows
Form

'Elle peut être modifiée en utilisant le Concepteur




Windows Form.

'Ne la modifiez pas en utilisant l'éditeur de code.

Friend WithEvents VScrollBar1 As




System.Windows.Forms.VScrollBar

Friend WithEvents PictureBox1 As




System.Windows.Forms.PictureBox

<System.Diagnostics.DebuggerStepThrough()> Private Sub


InitializeComponent()

Me.VScrollBar1 = New System.Windows.Forms.VScrollBar

Me.PictureBox1 = New System.Windows.Forms.PictureBox

Me.SuspendLayout()

'

'VScrollBar1

'

Me.VScrollBar1.LargeChange = 1

Me.VScrollBar1.Location = New System.Drawing.Point(256,




32)

Me.VScrollBar1.Name = "VScrollBar1"

Me.VScrollBar1.Size = New System.Drawing.Size(17, 208)

Me.VScrollBar1.TabIndex = 3

'

'PictureBox1

'

Me.PictureBox1.Location = New System.Drawing.Point(16,




40)

Me.PictureBox1.Name = "PictureBox1"

Me.PictureBox1.Size = New System.Drawing.Size(224, 200)

Me.PictureBox1.TabIndex = 4

Me.PictureBox1.TabStop = False

'

'Form2

'

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

Me.ClientSize = New System.Drawing.Size(292, 266)

Me.Controls.Add(Me.PictureBox1)

Me.Controls.Add(Me.VScrollBar1)

Me.Name = "Form2"

Me.Text = "Form2"

Me.ResumeLayout(False)

End Sub

#End Region

Private oB As New Bitmap("C:feu_camp3.gif")

Private Sub Form1_Load(ByVal sender As Object, ByVal e




As
System.EventArgs)
Handles MyBase.Load

Dim oFD As New
System.Drawing.Imaging.FrameDimension




(oB.FrameDimensionsList(0))

Me.VScrollBar1.Maximum = oB.GetFrameCount(oFD) - 1

End Sub



Private Sub pic2_Paint(ByVal sender As System.Object,




ByVal e As
System.Windows.Forms.PaintEventArgs) Handles




PictureBox1.Paint

Dim oFD As New
System.Drawing.Imaging.FrameDimension




(oB.FrameDimensionsList(0))

oB.SelectActiveFrame(oFD, Me.VScrollBar1.Value)

e.Graphics.DrawImage(oB, 0, 0)

End Sub

Private Sub VScrollBar1_Scroll(ByVal sender As




System.Object, ByVal e As
System.Windows.Forms.ScrollEventArgs) Handles




VScrollBar1.Scroll

Me.PictureBox1.Invalidate()

End Sub

End Class


"Olivier Bonneau"




a écrit dans
le
message de news: B7C8D686-1039-4DE2-B50E-





> Bonjour,
>
> comment stoper l'animation d'un gif animé ?
>
> merci,
> olivier.
> --
> -----------------------
> il y a 10 sortent de personnes, celle qui comprennent




le binaire et les
> autres ...
> -----------------------
> Toutes mes fautes d'ortographes sont volontaires ! ;-)






.



Avatar
David Bouchard
Désolé, mon but n'est pas de voler les idées mais d'aidé, j'ai retrouvé
cette source dans mes affaires et je n'ai rien qui indique de ou elle
parvient.

David

"TocToc" a écrit dans le message de
news: 002a01c4dc83$8064e960$

MDR, ca casse un homme ca :)
-----Message d'origine-----
Merci de citer vos sources


d'inspiration !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

http://www.c2i.fr/code.aspx?IDCode97

--
Richard Clark
http://www.c2i.fr - Le portail .NET
[Microsoft MVP .NET]
______________________________________________
Etudiants, lycéens, partez au Japon et gagnez $8000
http://www.project-hoshimi.fr
______________________________________________

"David Bouchard" wrote in


message
news:
Voici un poste que j'avais répondu plus bas. >>>>


Voici deux section de code que tu pourrais trouvé très




intéressante sur
les
gifs animés, ceci fonctionne très bien.

Crée toi deux formulaires et remplace le contenu de




chacun par une des
sections de code. La première te permet de comprendre




comment dessiner un
gif animé et la seconde comment choisir le frame du gif




que tu désire
dessiner.

David

Public Class Form1

Inherits System.Windows.Forms.Form

#Region " Code généré par le Concepteur Windows Form "

Public Sub New()

MyBase.New()

'Cet appel est requis par le Concepteur Windows Form.

InitializeComponent()

MyInitializeComponent()

'Ajoutez une initialisation quelconque après l'appel




InitializeComponent()

End Sub

'La méthode substituée Dispose du formulaire pour




nettoyer la liste des
composants.

Protected Overloads Overrides Sub Dispose(ByVal




disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

'Requis par le Concepteur Windows Form

Private components As System.ComponentModel.IContainer

'REMARQUE : la procédure suivante est requise par le




Concepteur Windows
Form

'Elle peut être modifiée en utilisant le Concepteur




Windows Form.

'Ne la modifiez pas en utilisant l'éditeur de code.

Friend WithEvents Button1 As System.Windows.Forms.Button

Friend WithEvents PictureBox1 As




System.Windows.Forms.PictureBox

<System.Diagnostics.DebuggerStepThrough()> Private Sub


InitializeComponent()

Me.Button1 = New System.Windows.Forms.Button

Me.PictureBox1 = New System.Windows.Forms.PictureBox

Me.SuspendLayout()

'

'Button1

'

Me.Button1.Location = New System.Drawing.Point(16, 8)

Me.Button1.Name = "Button1"

Me.Button1.TabIndex = 0

Me.Button1.Text = "Button1"

'

'PictureBox1

'

Me.PictureBox1.Location = New System.Drawing.Point(24,




80)

Me.PictureBox1.Name = "PictureBox1"

Me.PictureBox1.Size = New System.Drawing.Size(192, 160)

Me.PictureBox1.TabIndex = 1

Me.PictureBox1.TabStop = False

'

'Form1

'

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

Me.ClientSize = New System.Drawing.Size(400, 266)

Me.Controls.Add(Me.PictureBox1)

Me.Controls.Add(Me.Button1)

Me.Name = "Form1"

Me.Text = "Form1"

Me.ResumeLayout(False)

End Sub

#End Region



Private _bAnimated As Boolean

Private _Bitmap As Bitmap

Private Sub MyInitializeComponent()

_Bitmap = New Bitmap("C:feu_camp3.gif")

ToogleAnimation()

End Sub

Private Sub ToogleAnimation()

If Not ImageAnimator.CanAnimate(_Bitmap) Then Exit Sub

If _bAnimated Then

ImageAnimator.StopAnimate(_Bitmap, New EventHandler




(AddressOf
Me.OnFrameChanged))

Else

ImageAnimator.Animate(_Bitmap, New EventHandler




(AddressOf
Me.OnFrameChanged))

End If

_bAnimated = Not _bAnimated

End Sub

Private Sub OnFrameChanged(ByVal sender As Object,




ByVal e As EventArgs)

Me.PictureBox1.Invalidate()

End Sub

Private Sub picAff_Paint(ByVal sender As Object, ByVal




e As
System.Windows.Forms.PaintEventArgs) Handles




PictureBox1.Paint

ImageAnimator.UpdateFrames()

e.Graphics.DrawImage(_Bitmap, New Point(0, 0))

End Sub

Private Sub Button1_Click(ByVal sender As




System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

If _bAnimated Then

Me.Button1.Text = "&Start"

Else

Me.Button1.Text = "&Stop"

End If

ToogleAnimation()

End Sub

End Class









Public Class Form2

Inherits System.Windows.Forms.Form

#Region " Code généré par le Concepteur Windows Form "

Public Sub New()

MyBase.New()

'Cet appel est requis par le Concepteur Windows Form.

InitializeComponent()

'Ajoutez une initialisation quelconque après l'appel




InitializeComponent()

End Sub

'La méthode substituée Dispose du formulaire pour




nettoyer la liste des
composants.

Protected Overloads Overrides Sub Dispose(ByVal




disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

'Requis par le Concepteur Windows Form

Private components As System.ComponentModel.IContainer

'REMARQUE : la procédure suivante est requise par le




Concepteur Windows
Form

'Elle peut être modifiée en utilisant le Concepteur




Windows Form.

'Ne la modifiez pas en utilisant l'éditeur de code.

Friend WithEvents VScrollBar1 As




System.Windows.Forms.VScrollBar

Friend WithEvents PictureBox1 As




System.Windows.Forms.PictureBox

<System.Diagnostics.DebuggerStepThrough()> Private Sub


InitializeComponent()

Me.VScrollBar1 = New System.Windows.Forms.VScrollBar

Me.PictureBox1 = New System.Windows.Forms.PictureBox

Me.SuspendLayout()

'

'VScrollBar1

'

Me.VScrollBar1.LargeChange = 1

Me.VScrollBar1.Location = New System.Drawing.Point(256,




32)

Me.VScrollBar1.Name = "VScrollBar1"

Me.VScrollBar1.Size = New System.Drawing.Size(17, 208)

Me.VScrollBar1.TabIndex = 3

'

'PictureBox1

'

Me.PictureBox1.Location = New System.Drawing.Point(16,




40)

Me.PictureBox1.Name = "PictureBox1"

Me.PictureBox1.Size = New System.Drawing.Size(224, 200)

Me.PictureBox1.TabIndex = 4

Me.PictureBox1.TabStop = False

'

'Form2

'

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

Me.ClientSize = New System.Drawing.Size(292, 266)

Me.Controls.Add(Me.PictureBox1)

Me.Controls.Add(Me.VScrollBar1)

Me.Name = "Form2"

Me.Text = "Form2"

Me.ResumeLayout(False)

End Sub

#End Region

Private oB As New Bitmap("C:feu_camp3.gif")

Private Sub Form1_Load(ByVal sender As Object, ByVal e




As
System.EventArgs)
Handles MyBase.Load

Dim oFD As New
System.Drawing.Imaging.FrameDimension




(oB.FrameDimensionsList(0))

Me.VScrollBar1.Maximum = oB.GetFrameCount(oFD) - 1

End Sub



Private Sub pic2_Paint(ByVal sender As System.Object,




ByVal e As
System.Windows.Forms.PaintEventArgs) Handles




PictureBox1.Paint

Dim oFD As New
System.Drawing.Imaging.FrameDimension




(oB.FrameDimensionsList(0))

oB.SelectActiveFrame(oFD, Me.VScrollBar1.Value)

e.Graphics.DrawImage(oB, 0, 0)

End Sub

Private Sub VScrollBar1_Scroll(ByVal sender As




System.Object, ByVal e As
System.Windows.Forms.ScrollEventArgs) Handles




VScrollBar1.Scroll

Me.PictureBox1.Invalidate()

End Sub

End Class


"Olivier Bonneau"




a écrit dans
le
message de news: B7C8D686-1039-4DE2-B50E-





> Bonjour,
>
> comment stoper l'animation d'un gif animé ?
>
> merci,
> olivier.
> --
> -----------------------
> il y a 10 sortent de personnes, celle qui comprennent




le binaire et les
> autres ...
> -----------------------
> Toutes mes fautes d'ortographes sont volontaires ! ;-)






.