次の方法で共有


ImageAnimator.Animate メソッド

多重フレーム イメージをアニメーションで表示します。

Public Shared Sub Animate( _
   ByVal image As Image, _   ByVal onFrameChangedHandler As EventHandler _)
[C#]
public static void Animate(Imageimage,EventHandleronFrameChangedHandler);
[C++]
public: static void Animate(Image* image,EventHandler* onFrameChangedHandler);
[JScript]
public static function Animate(
   image : Image,onFrameChangedHandler : EventHandler);

パラメータ

  • image
    アニメーション化する Image オブジェクト。
  • onFrameChangedHandler
    アニメーション フレームが変更されたときに呼び出されるメソッドを指定する EventHandler オブジェクト。

戻り値

このメソッドは値を返しません。

使用例

[Visual Basic, C#] この Windows フォーム アプリケーションは、アニメーション イメージが画面にどのように描画されるかを示します。このイメージは、アプリケーションと同じフォルダに保存されているアニメーション GIF ファイルの SampleAnimation.gif から作成されます。

 
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Public Class animateImage
Inherits Form
'Create a Bitmpap Object.
Private animatedImage As New Bitmap("SampleAnimation.gif")
Private currentlyAnimating As Boolean = False
'This method begins the animation.
Public Sub AnimateImage()
If Not currentlyAnimating Then
'Begin the animation only once.
ImageAnimator.Animate(animatedImage, _
New EventHandler(AddressOf Me.OnFrameChanged))
currentlyAnimating = True
End If
End Sub
Private Sub OnFrameChanged(o As Object, e As EventArgs)
'Force a call to the Paint event handler.
Me.Invalidate()
End Sub
Protected Overrides Sub OnPaint(e As PaintEventArgs)
'Begin the animation.
AnimateImage()
'Get the next frame ready for rendering.
ImageAnimator.UpdateFrames()
'Draw the next frame in the animation.
e.Graphics.DrawImage(Me.animatedImage, New Point(0, 0))
End Sub
Public Shared Sub Main()
Application.Run(New animateImage())
End Sub
End Class
        
[C#] 
using System;
using System.Drawing;
using System.Windows.Forms;
public class animateImage : Form {
//Create a Bitmpap Object.
Bitmap animatedImage = new Bitmap("SampleAnimation.gif");
bool currentlyAnimating = false;
//This method begins the animation.
public void AnimateImage() {
if (!currentlyAnimating) {
//Begin the animation only once.
ImageAnimator.Animate(animatedImage, new EventHandler(this.OnFrameChanged));
currentlyAnimating = true;
}
}
private void OnFrameChanged(object o, EventArgs e) {
//Force a call to the Paint event handler.
this.Invalidate();
}
protected override void OnPaint(PaintEventArgs e) {
//Begin the animation.
AnimateImage();
//Get the next frame ready for rendering.
ImageAnimator.UpdateFrames();
//Draw the next frame in the animation.
e.Graphics.DrawImage(this.animatedImage, new Point(0, 0));
}
public static void Main() {
Application.Run(new animateImage());
}
}
        

[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

ImageAnimator クラス | ImageAnimator メンバ | System.Drawing 名前空間