Click here to Skip to main content
Click here to Skip to main content

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

, 6 Jul 2007
Rate this:
Please Sign up or sign in to vote.
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

Introduction

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

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
{
    get 
    { 
        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

License

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

Share

About the Author

nguyenthanhtungtinbk
Team Leader
Vietnam Vietnam


PERSONAL DETAILS


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

PERSONAL PROFILE

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

 

AREA OF EXPERTISE

    • 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 ...
     


    MAIN PROJECTS DONE IN THE PAST
    • 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

 
GeneralMy vote of 1 Pinmemberlemycanh24-Jul-09 8:05 
GeneralAnother solution, but controls not seen Pinmembereusta26-Nov-07 10:02 
GeneralRe: Another solution, but controls not seen Pinmembereusta27-Nov-07 4:57 
GeneralUmm... PinmemberBoneSoft10-Jul-07 5:20 
QuestionCan we save these multiple images as a multiframe GIF Image Pinmembersachit120-Jul-06 23:51 
AnswerRe: Can we save these multiple images as a multiframe GIF Image PinmemberNguyê~n Thanh Tùng21-Jul-06 0:48 
AnswerRe: Can we save these multiple images as a multiframe GIF Image PinmemberNguyê~n Thanh Tùng21-Jul-06 1:39 
QuestionRe: Can we save these multiple images as a multiframe GIF Image PinmemberTejasBhai15-Aug-06 20:17 
QuestionControls on the Alpha-Blended Form PinmemberAllen G12-Apr-06 2:16 
AnswerRe: Controls on the Alpha-Blended Form PinmemberNguyê~n Thanh Tùng12-Apr-06 4:13 
Yes, the solution is creating 2 forms and those will move together (same co-ordinations). One form contains controls and the other is the Alpha-Blended Form. Then you make the controls-contained form transparency (not using PNG).
 
There is another way but it's very complex Blush | :O
QuestionRe: Controls on the Alpha-Blended Form PinmemberAssaf Koren21-Apr-06 0:11 
QuestionGIF Version Pinmemberjumacabo18-Oct-05 21:11 
AnswerRe: GIF Version PinmemberNguyê~n Thanh Tùng18-Oct-05 21:25 

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

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

| Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 6 Jul 2007
Article Copyright 2005 by nguyenthanhtungtinbk
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid