Animated gif on Transparent Form - with problem!

dagelmyster

New member
Joined
Dec 13, 2004
Messages
2
Programming Experience
3-5
I just recently moved from vb6 to .net and am still having a couple problems. Can anybody help me out?

I have a animated gif on a transparent form that works but the mask(I assume thats what it is) from the first frame of the gif doesn't animate along with it, so you can see it behind the animating gif. Also, the animation isn't quite lining up with the 'mask'. The animation works when transparency isn't used. Here's the code if it helps:


Imports System.Windows.Forms
Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
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

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(100, 116)
Me.ControlBox = False
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
Me.MaximizeBox = False
Me.Name = "Form1"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Form1"

End Sub
#End Region
Private myIrregular As New clsIrregular
Private myBMP As Bitmap
Private myImagePosition As Point

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
myBMP = New Bitmap(Application.StartupPath() & "\..\dog.gif")
ImageAnimator.Animate(myBMP, New EventHandler(AddressOf OnFrameChange))
myImagePosition = New Point(CInt(Me.ClientSize.Width / 2 - myBMP.Width / 2), _
CInt(Me.ClientSize.Height / 2 - myBMP.Height / 2))
SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.DoubleBuffer Or _
ControlStyles.UserPaint, True)

myIrregular.ScanBitmap(myBMP)
myIrregular.SetFormToScannedBitmapSize(Me)
myIrregular.ApplyScannedBitmap(Me.BackgroundImage)
myIrregular.ApplyScannedBitmapRegion(Me.Region)
End Sub

Private Sub OnFrameChange(ByVal sender As Object, ByVal e As EventArgs)
Me.Invalidate()
End Sub

Private Sub Form1_DoubleClick(ByVal sender As Object, ByVal e As _
System.EventArgs) Handles MyBase.DoubleClick
Me.Close()
End Sub

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As _
System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
If Not myBMP Is Nothing Then
ImageAnimator.UpdateFrames(myBMP)
Dim tmpBMP As New Bitmap(myBMP, myBMP.Width, myBMP.Height)
tmpBMP.MakeTransparent(tmpBMP.GetPixel(0, 0))
e.Graphics.DrawImage(tmpBMP, myImagePosition)
tmpBMP.Dispose()
End If
End Sub
End Class

Thanks for any help!
 
Back
Top