An Image (GIF, JPEG, BMP, ICO, WMF and EMF) Viewer | CodeGuru

An Image (GIF, JPEG, BMP, ICO, WMF and EMF) Viewer

Environment: Visual C++ 6.0 with Service Pack 3, Windows 9x, Windows NT 4.0 with Service Pack 6a and Windows 2000 This sample is an MFC application using the document/view architecture that can load, display, and print graphics files such aske GIF, JPEG, BMP (bitmap), ICO (icon), WMF (metafile), and EMF (Win32-enhanced metafile). It shows: how […]

Written By
CodeGuru Staff
CodeGuru Staff
Oct 10, 2002
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

ImgViewer

Environment: Visual C++ 6.0 with Service Pack 3, Windows 9x, Windows NT 4.0 with Service Pack 6a and Windows 2000

This sample is an MFC application using the document/view architecture that can load, display, and print graphics files such aske GIF, JPEG, BMP (bitmap), ICO (icon), WMF (metafile), and EMF (Win32-enhanced metafile). It shows:

  • how to use the OleLoadPicturePath function and the IPicture interface to load and display those graphics files.
  • (Look into the ImgViewerDoc.cpp, ImgViewerView.cpp, and MainFrm.cpp files.)

  • how to support more than one file extension per MFC document type.
  • (Look into the MulExtDocTmp.cpp, MulExtDocTmp.h, and ImgViewer.cpp files.)

References:

Please see the following articles in the Microsoft Knowledge Base:

Q218972How To Load and Display Graphics Files w/LOADPIC.EXE
(Note that LOADPIC.EXE does not handle palettes. As a result, it won’t display a 256-color image correctly in 256-color mode. Also, it uses the OleLoadPicture function instead of the OleLoadPicturePath function.)

Q141921HOWTO: How to Support Two File Extensions per MFC Document Type
Q198538DocMgrEx.exe Assoc Multiple File Extensions w/1 Doc Type

Downloads

Download Source Code – 153 KB

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.