Click here to Skip to main content
15,884,099 members
Articles / Desktop Programming / MFC

Drawing transparent bitmaps using CImage

Rate me:
Please Sign up or sign in to vote.
4.92/5 (21 votes)
17 Sep 20017 min read 564.1K   13.1K   160  
Universal implementation of transparent drawing of bitmap files (BMP, JPEG, GIF, PNG). Based on the method described by Chris Becke and Raja Segar.
// demo.h : main header file for the DEMO application
//

#ifndef __AFXWIN_H__
	#error include 'stdafx.h' before including this file for PCH
#endif

#include "resource.h"       // main symbols

/////////////////////////////////////////////////////////////////////////////
// CApp:
// See demo.cpp for the implementation of this class
//

class CApp : public CWinApp
{
public:
	CApp();

// Attributes
protected:
   static CApp m_app;

   int m_nFilterIndex;
public:
	int m_nDocCount;	//number of documents
	CMultiDocTemplate *demoTemplate;

	// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CApp)
	public:
	virtual BOOL InitInstance();
	//}}AFX_VIRTUAL

// Operations
public:
   static CApp& GetApp(void);

   BOOL PromptForFileName(CString& fileName, UINT nIDSTitle, DWORD dwFlags, BOOL bOpenFileDialog, int* pType=NULL);
	int GetIndexFromType(int nDocType, BOOL bOpenFileDialog);
	int GetTypeFromIndex(int nIndex, BOOL bOpenFileDialog);
	CString GetExtFromType(int nDocType);
	CString GetFileTypes(BOOL bOpenFileDialog);
	BOOL GetWritableType(int nDocType);

// Implementation

	//{{AFX_MSG(CApp)
	afx_msg void OnAppAbout();
   afx_msg void OnFileOpen() ;
	afx_msg void OnImageFromBitmap();
	afx_msg void OnLoadJpegResource();
	afx_msg void OnLoadIconResource();
	afx_msg void OnLoadGifResource();
	afx_msg void OnLoadPngResource();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

   friend class CFrame;
};

struct DocType
{
public:
	BOOL bRead;
	BOOL bWrite;
	LPCTSTR description;
	LPCTSTR ext;
};

/////////////////////////////////////////////////////////////////////////////

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

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


Written By
Denmark Denmark
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions