Click here to Skip to main content
15,568,681 members
Articles / Mobile Apps / Smartwatch
Posted 18 Oct 2005


65 bookmarked

Create animation in dotNet with alpha-blending PNG images by calling API

Rate me:
Please Sign up or sign in to vote.
3.87/5 (94 votes)
6 Jul 2007
This article shows you the advantage of PNG images with alpha-blending feature in creating animation and demonstates how to use PNG images in Framework.NET application by calling API

Sample Image - revolution.jpg


A lot of coders (including myself before) have given up working with PNG because it's not so easy to make PNG background image to work smoothly. However, PNG is a very good image format which allows you to use transparency with alpha-blending feature. This article will show you how to make PNG work and the advantage of using it in creating animation.

Secret inside

clsTungPngAnimation inherits the abstract class clsTungAnimation since we intend to have many of the same functions in clsTungPngAnimation and clsTungBmpAnimation. All these classes can be found in clsTungAnimation.cs

Image 2

frmAnimation.cs (for PNG) and frmBmpAnimation.cs (for BMP) are where picture frames will appear in. If we use PNG, this function must be used to make the form transparent but still can keep alpha-blending of PNG pictures:

protected override CreateParams CreateParams
        CreateParams cp = base.CreateParams;
        cp.ExStyle |= 0x00080000; //WS_EX_LAYERED    
        return cp;

(This function is inside frmAnimation.cs)

clsBitmapTransparent.cs is used to create PNG transparent background for the form.

clsBitmapRegion.cs is used to create a region of a form from loading BMP images so that images will appear transparent.

Trung tam di dong qui tu cac cua hang lon nhat Vietnam


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Written By
Team Leader
Vietnam Vietnam


Full Name : Nguyen Thanh Tung
Sex : Male
Date of Birth : October 06, 1983
Nationality : Vietnamese


Trustworthy, efficient, capable work under pressure, outgoing person and capable work in a team.


    • Proficient in Programming: .Net 1.0/1.1/2.0/3.0/3.5 (C#, VB.Net, ASP.Net,
      AJAX, WCF, WWF), VB4/5/6, ASP, PHP, HTML, CSS, Script, XML.
      Experience with Vs Source Safe, Team System, MsBuild, SVN/CVS. Knowledge about
      UnitTest, Test-Driven development.
    • Experience with Databases: SQL Server 2000/2005, MySQL
      4.x/5.x/6.x, Oracle, PostgreSQL, Ms. Access.
    • Experience in EIS: ERP, CRM, SCM ...
    • Experience with Microsoft Products: CRM3/4, Sharepoint
      2003/2007 ...
    • Proficient in OS: Linux (Redhat, Fedora, Mandrake, Suse), Windows (2000/2003
      Server, XP, Vista).
    • Proficient in Graphics (Flash, Photoshop, 3DMax …); Microsoft Office, Visio,
      Microsoft Project.
    • Proficient in Network Devices: Router, Switch, Firewall Server, Mail Server,
      FTP Server, DNS, VPN.
      Experience in Servers: IBM, HP, Sun, Dell ...
    • Familiar with OO and SOA concepts.
    • Knowledge about project management: CMMI, Agile and Scrum, Software
      Engineering, System Analysis and Design, IT Project Management. 
    • Knowledge in Accounting and Finance: Financial Statement, Income
      Statement ...


    • SMS Gateway.
    • POP3-IMAP-SMTP App.
    • Products Management Sys.
    • Hedge Fund Management Sys.
    • Motion detection.
    • 3D games engine (C# using OpenGL Lib).
    • Video Conference.
    • Information Retrieval.
    • Microsoft CRM3/4
    • Microsoft Sharepoint Portal 2003/2007
    • CMS
    • E-Commerce

Comments and Discussions

GeneralAnother solution, but controls not seen Pin
eusta26-Nov-07 11:02
eusta26-Nov-07 11:02 
GeneralRe: Another solution, but controls not seen Pin
eusta27-Nov-07 5:57
eusta27-Nov-07 5:57 
Can you answer my question?
GeneralUmm... Pin
BoneSoft10-Jul-07 6:20
BoneSoft10-Jul-07 6:20 
QuestionCan we save these multiple images as a multiframe GIF Image Pin
sachit121-Jul-06 0:51
sachit121-Jul-06 0:51 
AnswerRe: Can we save these multiple images as a multiframe GIF Image Pin
nguyenthanhtungtinbk21-Jul-06 1:48
nguyenthanhtungtinbk21-Jul-06 1:48 
AnswerRe: Can we save these multiple images as a multiframe GIF Image Pin
nguyenthanhtungtinbk21-Jul-06 2:39
nguyenthanhtungtinbk21-Jul-06 2:39 
QuestionRe: Can we save these multiple images as a multiframe GIF Image Pin
TejasBhai15-Aug-06 21:17
TejasBhai15-Aug-06 21:17 
QuestionControls on the Alpha-Blended Form Pin
Allen G12-Apr-06 3:16
Allen G12-Apr-06 3:16 
AnswerRe: Controls on the Alpha-Blended Form Pin
nguyenthanhtungtinbk12-Apr-06 5:13
nguyenthanhtungtinbk12-Apr-06 5:13 
QuestionRe: Controls on the Alpha-Blended Form Pin
Assaf Koren21-Apr-06 1:11
Assaf Koren21-Apr-06 1:11 
QuestionGIF Version Pin
jumacabo18-Oct-05 22:11
jumacabo18-Oct-05 22:11 
AnswerRe: GIF Version Pin
nguyenthanhtungtinbk18-Oct-05 22:25
nguyenthanhtungtinbk18-Oct-05 22:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.