Click here to Skip to main content
Licence 
First Posted 16 May 2004
Views 47,001
Bookmarked 14 times

CVisualEffect

By | 16 May 2004 | Article
A CStatic derived class to show some visual effects on images.

Sample Image - VisualEffect1.jpg

Introduction

In this article, I want to show you a way for creating a simple visual effect. I use some image processing techniques and a very useful library called CImg written by David Tschumperlé to create this CStatic derived funny control.

How to use

First of all, add the following files to your project: VisualEffect.h, VisualEffect.cpp, CImg.h and CImg.cpp. Most of the work for creating the images on the fly was done in CImg.h header file. In VisualEffect.h, two classes were defined: CVisualEffect and CImgDisplayEx (an extended version of CImgDisplay for adapting it with our CStatic derived class: CVisualEffect).

In the dialog resource editor, add new static control and rename its ID from IDC_STATIC to IDC_VISUAL_EFFECT. See figure 2 for more information.

Run class wizard for assigning new member variable to your dialog as type of CVisualEffect (Figure 3).

If class wizard couldn't recognize CVisualEffect class, select CStatic, then rename type of your variable from CStatic to CVisualEffect. Remember that you must add #include "VisualEffect.h" at the top of your dialog header file.

CVisualEffect class has two important member functions:

void SetImage(CString FileName);

Use this member function for setting an image to be loaded by the class. The class will show the effected image after calling DrawImage() member function.

void DrawImage();

This member function must create visually effected images on the fly and show them with the help of a thread.

CVisualEffect class

The CVisualEffect is a CStatic derived class and has the following definition:

class CVisualEffect : public CStatic
{
// Construction
public:
    CVisualEffect();
    void SetImage(CString FileName);
    void DrawImage();

// Attributes
public:
    CImg<float>    m_Original;
    CImgDisplayEx    m_Display;


// Implementation
public:
    static UINT DrawThread(LPVOID pParam);
    virtual ~CVisualEffect();

    // Generated message map functions
protected:
    //{{AFX_MSG(CVisualEffect)
    //}}AFX_MSG

    DECLARE_MESSAGE_MAP()
};

m_Display is a member variable of type CImgDisplayEx. This class sets a target window for fast image manipulation.

Enjoy!

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

About the Author

A. Riazi



Iran (Islamic Republic Of) Iran (Islamic Republic Of)

Member

I was born in Shiraz, a very beautiful famous city in Iran. I started programming when I was 12 years old with GWBASIC. Since now, I worked with various programming languages from Basic, Foxpro, C/C++, Visual Basic, Pascal to MATLAB and now Visual C++.
I graduated from Iran University of Science & Technology in Communication Eng., and now work as a system programmer for a telecommunication industry.
I wrote several programs and drivers for Synthesizers, Power Amplifiers, GPIB, GPS devices, Radio cards, Data Acqusition cards and so many related devices.
I'm author of several books like Learning C (primary and advanced), Learning Visual Basic, API application for VB, Teach Yourself Object Oriented Programming (OOP) and etc.
I'm winner of January, May, August 2003 and April 2005 best article of month competetion, my articles are:

You can see list of my articles, by clicking here



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 5 Pinmembermanoj kumar choubey19:49 26 Feb '12  
GeneralDeleting Image PinmemberHeatherH7:38 21 Apr '07  
Generalconvert Pinmemberdenishernandez13:49 16 Feb '06  
GeneralRe: convert PinmemberA. Riazi3:30 17 Feb '06  
GeneralCrashes in XP SP2 PinmemberBalkrishna Talele20:07 1 Oct '04  
GeneralAlmost worthless. PinmemberWREY12:01 17 May '04  
GeneralRe: Almost worthless. PinmemberA. Riazi18:34 17 May '04  
General100% CPU usage PinsussAnonymous11:12 17 May '04  

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.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 17 May 2004
Article Copyright 2004 by A. Riazi
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid