Click here to Skip to main content
6,304,948 members and growing! (18,019 online)
Email Password   helpLost your password?
Platforms, Frameworks & Libraries » Mobile Development » Graphics and Multimedia     Intermediate

A Picture Viewer for the Pocket PC 2002

By Joao Paulo Figueira

Putting imgdecmp.lib to work with a few extras.
C++, eVC 3.0, Windows, PocketPC 2002, Visual Studio, MFC, Dev
Posted:9 Mar 2003
Updated:2 Nov 2003
Views:203,224
Bookmarked:38 times
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
21 votes for this article.
Popularity: 6.00 Rating: 4.54 out of 5
1 vote, 5.0%
1
1 vote, 5.0%
2
1 vote, 5.0%
3
2 votes, 10.0%
4
15 votes, 75.0%
5

Sample Image - PicView1.jpg

Introduction

This is a very simple picture viewer that illustrates some implementation details that you might want to use in your own Pocket PC 2002 projects. These are:

  • Using the imgdecmp.lib for loading BMP, JPEG and GIF image files.
  • Implementing a "tap-and-scroll" for scrolling convenience.
  • Implementing a full screen view.
  • Removing the "New" button from a Document / View toolbar.
  • Adding a title bar to the view (new)

Application architecture

This application uses the MFC's Document / View architecture in order to ease implementation. Bitmap pictures are drawn in a CScrollView-derived class, with a special support for the "tap-and-scroll" functionality. This allows the user to scroll the bitmap using the stylus, by tapping and dragging it. The document does not allow saving (after all, this is a viewer), but supports zooming. The zoom in and zoom out commands are supported at the document level although, arguably, they could be implemented at the view level.

Loading images

Images are loaded through a sparsely-documented API, implemented through the imgdecmp.lib. Both this library and its header are distributed with the PPC2002 SDK. Apparently, this is the same mechanism that is used by Pocket IE to load its images from the Internet, and that is why it supports a packet architecture. As for file formats, it is reported to support BMP, JPEG and GIF, but it may support more.

Images are loaded in CPicViewDoc::Serialize(). The process (see source) involves calling the DecompressImageIndirect() function, the DecompressImageInfo structure and two callback functions. The first callback function - GetImageData() - is used to read the image data in chunks, whereas the second - ImageProgress() - is used to report the image loading progress. In this sample, the callback does nothing (but yes, it must be there).

The fields of the DecompressImageInfo structure are quite self-explanatory, with one exception: lParam. This is the parameter that is passed to the callback functions, and I use it to carry a pointer to a structure containing a pair of values (ReadBmp): the CFile pointer retrieved from the open CArchive, and a counter of the image size. This is not strictly necessary for this application because one file has just one image, so passing the CFile* in lParam would be enough. This technique is used because it allows for extensibility, in the case where the file has multiple images, such as a skin file. Here you cannot rely in the end-of-file stop rendering the bitmap.

Tap-And-Scroll

This technique allows scrolling the image with a tap and drag sequence. The image will follow the stylus, scrolling automatically. The scroll bars are also present and active.

In order to achieve this effect, the view handles both OnLButtonDown() and OnMouseMove() (see code). The first stores the tap point, and the second calculates the scroll vector. This vector is then used in the ScrollTo() method, where the new scroll position is calculated. Note that this code was directly adapted from MFC's sources in order to avoid the unpleasant "jagged" scrolling one gets by using CScrollView::ScrollToPosition(). This method does not allow scrolling in both x and y directions simultaneously.

Full screen view

In the Pocket PC 2002, the full screen functionality is achieved through the SHFullScreen API. This function allows the application to position its main window over areas that are usually controlled by the system, such as the SIP and the taskbar. The code that achieves this is in the CMainFrame::OnFullScreen() handler. In order to support full screen toggling, a context menu is available through the tap-and-hold command. This menu allows you to enter and leave the full screen mode, as well as to issue Zoom In and Zoom Out commands.

The New button

Because this is just a viewer, the New button was removed from the main menu using a technique designed by Vassili Philippov. The original article is here: How to remove New button from command bar?

Title bar

Updated on October 27, 2003. The sample application now supports a title bar for displaying the image's file name. This title bar can be hidden or shown via a menu option, under Tools.

This title bar is implemented through the CCeTitleBar class, a CControlBar-derived window. It merely displays the title text in a predefined font and color.

Using this class is very straightforward (see source code). The window is created on the view's OnCreate handler and destroyed in OnDestroy. The view's OnUpdate handler is used to set the title text (document file name). Showing and hiding the title bar is done in the view's OnShowTitle handler.

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

Joao Paulo Figueira


Member
João is a Microsoft Device Application Development MVP and partner at Primeworks, a company that develops remote database access software for Windows Mobile.
Occupation: Software Developer
Company: Primeworks
Location: Portugal Portugal

Other popular Mobile Development articles:

  • Writing Your Own GPS Applications: Part 2
    In part two of the series, the author of "GPS.NET" teaches developers how to write GPS applications suitable for the real world by mastering GPS precision concepts. Source code includes a working NMEA interpreter and sample high-precision application in C# and VB.NET.
  • Writing Your Own GPS Applications: Part I
    What is it that GPS applications need to be good enough to use for in-car navigation? Also, how does the process of interpreting GPS data actually work? In this three-part series, I will cover both topics and give you the skills you need to write a commercial-grade GPS application.
  • Learn How to Find GPS Location on Any SmartPhone, and Then Make it Relevant
    A step by step tutorial for getting GPS from any SmartPhone, even without GPS built in, and then making location useful.
  • Pocket 1945 - A C# .NET CF Shooter
    An article on Pocket PC game development
  • iPhone UI in Windows Mobile
    It's an interface that works with transparency effects. As a sample I used an interface just like the iPhone one. In this tutorial I am explaining how simple is working with transparency on Windows Mobile.
Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 139 (Total in Forum: 139) (Refresh)FirstPrevNext
Generalwhat to do with hBmp after use? PinmemberKalian3:31 14 Jun '07  
GeneralRe: what to do with hBmp after use? PinmemberJoao Paulo Figueira8:43 14 Jun '07  
GeneralRe: what to do with hBmp after use? PinmemberKalian23:48 19 Jun '07  
GeneralHow to make folders permanent in PPC2002/ppc2003?? Pinmemberamit4all6:51 8 Apr '07  
Generalevc++ linking problem... PinmemberkillerLee20:27 18 Jun '06  
GeneralImage disappear Pinmemberhouari_id7:48 24 Mar '06  
GeneralRe: Image disappear PinmemberJoão Paulo Figueira0:27 25 Mar '06  
GeneralRe: Image disappear Pinmemberhouari_id3:45 25 Mar '06  
GeneralHow to show image from winsock buffer? Pinmemberrobert10142:02 16 Sep '05  
Generalevc++ linking problem... Helpp!!! Pinmemberviveksundaram4:25 10 Apr '05  
GeneralRe: evc++ linking problem... Helpp!!! PinmemberDaniel Jin5:15 24 Apr '05  
GeneralRe: evc++ linking problem... Helpp!!! PinmemberJohn Francis Shade1:32 1 Feb '06  
GeneralRe: evc++ linking problem... Helpp!!! PinmemberJohn Francis Shade22:34 1 Feb '06  
GeneralRe: evc++ linking problem... Helpp!!! Pinmemberjitendra lokwani21:42 21 Jul '06  
GeneralRe: evc++ linking problem... Helpp!!! PinmemberAndroides0:41 11 Oct '06  
GeneralPicView for evc 4.0 ? Pinmemberriki_risnandar3:06 26 Dec '04  
GeneralRe: PicView for evc 4.0 ? PinmemberJoão Paulo Figueira23:45 26 Dec '04  
GeneralRe: PicView for evc 4.0 ? Pinmemberriki_risnandar6:31 27 Dec '04  
GeneralRe: PicView for evc 4.0 ? PinmemberJoseph Ellsworth21:56 24 May '05  
GeneralRe: PicView for evc 4.0 ? Pinmemberriki_risnandar8:44 27 May '05  
GeneralRe: PicView for evc 4.0 ? Pinmemberavilap21:43 22 Jun '05  
GeneralRe: PicView for evc 4.0 ? Pinmemberkk022320:06 16 Jan '08  
GeneralRe: PicView for evc 4.0 ? Pinmemberwj840815@sohu.com22:42 27 Jan '08  
GeneralRe: PicView for evc 4.0 ? Pinmembercyg8015:51 17 Jul '06  
GeneralAccess the pixel PinmemberPeter00011:03 25 Dec '04  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 2 Nov 2003
Editor: Smitha Vijayan
Copyright 2003 by Joao Paulo Figueira
Everything else Copyright © CodeProject, 1999-2009
Web16 | Advertise on the Code Project