Click here to Skip to main content
13,345,438 members (48,211 online)
Click here to Skip to main content
Add your own
alternative version


13 bookmarked
Posted 17 Aug 2014

Image Converter

, 17 Aug 2014
Rate this:
Please Sign up or sign in to vote.
Quick tool to convert batch PNG images to ICO format


Image Converter (includes source code) is a free tool to convert between different image formats; it is based on CxImage class developed by Davide Pizzolato. I used it to convert PNG files from 1000+ Free “Farm-Fresh Web Icons” library to icons.

Image Converter

Using the code

The main processing is done in ConvertImage function:.

void CImageConverterDlg::ConvertImage(CString strFilePath)
	CString strMessage, strType = _T(".ico");

	m_nCurrentIcon = m_nDefaultIcon;

	TCHAR lpszDrive[_MAX_DRIVE];
	TCHAR lpszDirectory[_MAX_DIR];
	TCHAR lpszFilename[_MAX_FNAME];
	TCHAR lpszExtension[_MAX_EXT];

	VERIFY(0 == _tsplitpath_s(strFilePath, lpszDrive, _MAX_DRIVE, lpszDirectory, _MAX_DIR, lpszFilename, _MAX_FNAME, lpszExtension, _MAX_EXT));
	CString strConverted = m_strOutputFolder + lpszFilename + strType;

	CxImage pImage(strFilePath, GetTypeIdFromExt(lpszExtension));
	if (pImage.IsValid())
		if (pImage.Save(strConverted, GetTypeIdFromExt(strType)))
			pImage.Resample(16, 16);

			CBitmap* pBitmap = CBitmap::FromHandle(pImage.MakeBitmap());
			m_nCurrentIcon = m_pImageList.Add(pBitmap, RGB(0x00, 0x00, 0x00));

			strMessage.Format(_T("%s%s has been converted to %s%s ..."), lpszFilename, lpszExtension, lpszFilename, strType);
			DisplayMessage(m_nCurrentIcon, strMessage);


version 1.4 (August 18th, 2014) - Initial release.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Mihai MOGA
Architect Printec Group Romania SRL
Romania Romania
My professional background includes knowledge of analyst programmer for Microsoft Visual C++, Microsoft Visual C#, Microsoft Visual Basic, Sun Java, assembly for Intel 80x86 microprocessors, assembly for PIC microcontrollers (produced by Microchip Inc.), relational databases (MySQL, Oracle, SQL Server), concurrent version systems, bug tracking systems, web design (HTML5, CSS3, XML, PHP/MySQL, JavaScript, Flash).

If you like my articles, please visit my website for more:

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.180111.1 | Last Updated 18 Aug 2014
Article Copyright 2014 by Mihai MOGA
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid