Click here to Skip to main content
11,578,954 members (66,642 online)
Click here to Skip to main content

A Picture Viewer for the Pocket PC 2002

, 2 Nov 2003 CPOL 281.8K 530 43
Rate this:
Please Sign up or sign in to vote.
Putting imgdecmp.lib to work with a few extras.

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

João Paulo Figueira
Software Developer Frotcom International
Portugal Portugal
I work on R&D for Frotcom International, a company that develops web-based fleet management solutions.

You may also be interested in...

Comments and Discussions

 
Questionwhat to do with hBmp after use? Pin
Kalian14-Jun-07 2:31
memberKalian14-Jun-07 2:31 
AnswerRe: what to do with hBmp after use? Pin
Joao Paulo Figueira14-Jun-07 7:43
memberJoao Paulo Figueira14-Jun-07 7:43 
GeneralRe: what to do with hBmp after use? Pin
Kalian19-Jun-07 22:48
memberKalian19-Jun-07 22:48 
QuestionHow to make folders permanent in PPC2002/ppc2003?? Pin
amit4all8-Apr-07 5:51
memberamit4all8-Apr-07 5:51 
Generalevc++ linking problem... Pin
killerLee18-Jun-06 19:27
memberkillerLee18-Jun-06 19:27 
GeneralImage disappear Pin
houari_id24-Mar-06 6:48
memberhouari_id24-Mar-06 6:48 
GeneralRe: Image disappear Pin
João Paulo Figueira24-Mar-06 23:27
memberJoão Paulo Figueira24-Mar-06 23:27 
GeneralRe: Image disappear Pin
houari_id25-Mar-06 2:45
memberhouari_id25-Mar-06 2:45 
QuestionHow to show image from winsock buffer? Pin
robert101416-Sep-05 1:02
memberrobert101416-Sep-05 1:02 
Generalevc++ linking problem... Helpp!!! Pin
viveksundaram10-Apr-05 3:25
memberviveksundaram10-Apr-05 3:25 
GeneralRe: evc++ linking problem... Helpp!!! Pin
Daniel Jin24-Apr-05 4:15
memberDaniel Jin24-Apr-05 4:15 
GeneralRe: evc++ linking problem... Helpp!!! Pin
John Francis Shade1-Feb-06 0:32
memberJohn Francis Shade1-Feb-06 0:32 
GeneralRe: evc++ linking problem... Helpp!!! Pin
John Francis Shade1-Feb-06 21:34
memberJohn Francis Shade1-Feb-06 21:34 
GeneralRe: evc++ linking problem... Helpp!!! Pin
jitendra lokwani21-Jul-06 20:42
memberjitendra lokwani21-Jul-06 20:42 
GeneralRe: evc++ linking problem... Helpp!!! Pin
Androides10-Oct-06 23:41
memberAndroides10-Oct-06 23:41 
QuestionPicView for evc 4.0 ? Pin
riki_risnandar26-Dec-04 2:06
memberriki_risnandar26-Dec-04 2:06 
AnswerRe: PicView for evc 4.0 ? Pin
João Paulo Figueira26-Dec-04 22:45
memberJoão Paulo Figueira26-Dec-04 22:45 
There is no project converter between eVC3 and eVC4. You will have to create a new project using the wizard and then copy the old project files into it.

Regards,
João Paulo Figueira
Embedded MVP
GeneralRe: PicView for evc 4.0 ? Pin
riki_risnandar27-Dec-04 5:31
memberriki_risnandar27-Dec-04 5:31 
GeneralRe: PicView for evc 4.0 ? Pin
Joseph Ellsworth24-May-05 20:56
memberJoseph Ellsworth24-May-05 20:56 
GeneralRe: PicView for evc 4.0 ? Pin
riki_risnandar27-May-05 7:44
memberriki_risnandar27-May-05 7:44 
GeneralRe: PicView for evc 4.0 ? Pin
avilap22-Jun-05 20:43
memberavilap22-Jun-05 20:43 
GeneralRe: PicView for evc 4.0 ? Pin
kk022316-Jan-08 19:06
memberkk022316-Jan-08 19:06 
GeneralRe: PicView for evc 4.0 ? Pin
wj840815@sohu.com27-Jan-08 21:42
memberwj840815@sohu.com27-Jan-08 21:42 
AnswerRe: PicView for evc 4.0 ? Pin
cyg8017-Jul-06 14:51
membercyg8017-Jul-06 14:51 
GeneralAccess the pixel Pin
Peter000125-Dec-04 0:03
memberPeter000125-Dec-04 0:03 
GeneralRe: Access the pixel Pin
João Paulo Figueira25-Dec-04 0:19
memberJoão Paulo Figueira25-Dec-04 0:19 
GeneralRe: Access the pixel Pin
smallee25-Dec-04 1:56
membersmallee25-Dec-04 1:56 
GeneralRe: Access the pixel Pin
João Paulo Figueira26-Dec-04 0:32
memberJoão Paulo Figueira26-Dec-04 0:32 
GeneralI'm beginner.. please help me!!! Pin
ohns11-Dec-04 16:14
memberohns11-Dec-04 16:14 
GeneralRe: I'm beginner.. please help me!!! Pin
João Paulo Figueira12-Dec-04 0:17
memberJoão Paulo Figueira12-Dec-04 0:17 
QuestionCan I use it to open a file? Pin
ll2085020-Nov-04 2:39
memberll2085020-Nov-04 2:39 
AnswerRe: Can I use it to open a file? Pin
riki_risnandar26-Dec-04 3:11
memberriki_risnandar26-Dec-04 3:11 
GeneralHelp, please Pin
ll208505-Oct-04 8:11
memberll208505-Oct-04 8:11 
GeneralRe: Help, please Pin
ll208505-Oct-04 8:18
memberll208505-Oct-04 8:18 
GeneralAnimated GIF Pin
tyramanan20-Sep-04 22:08
membertyramanan20-Sep-04 22:08 
QuestionLoad specified Image/No Doc List? Pin
thollsten11-Jul-04 6:30
memberthollsten11-Jul-04 6:30 
AnswerRe: Load specified Image/No Doc List? Pin
João Paulo Figueira12-Jul-04 11:50
memberJoão Paulo Figueira12-Jul-04 11:50 
GeneralRe: Load specified Image/No Doc List? Pin
thollsten13-Jul-04 0:25
memberthollsten13-Jul-04 0:25 
GeneralError Pin
MaruKD24-Jun-04 5:53
memberMaruKD24-Jun-04 5:53 
GeneralRe: Error Pin
João Paulo Figueira12-Jul-04 11:28
memberJoão Paulo Figueira12-Jul-04 11:28 
GeneralPLS HELP...URGENT!!! Pin
starfish17-Jun-04 5:25
sussstarfish17-Jun-04 5:25 
GeneralRe: PLS HELP...URGENT!!! Pin
João Paulo Figueira17-Jun-04 12:44
memberJoão Paulo Figueira17-Jun-04 12:44 
GeneralRe: PLS HELP...URGENT!!! Pin
starfish18-Jun-04 1:03
sussstarfish18-Jun-04 1:03 
GeneralRe: PLS HELP...URGENT!!! Pin
jesuss2-Feb-05 14:59
memberjesuss2-Feb-05 14:59 
GeneralRe: PLS HELP...URGENT!!! Pin
João Paulo Figueira2-Feb-05 22:47
memberJoão Paulo Figueira2-Feb-05 22:47 
GeneralRe: PLS HELP...URGENT!!! Pin
Henrik Pettersson16-Mar-05 2:07
memberHenrik Pettersson16-Mar-05 2:07 
GeneralBuy Source code Pin
karl_hsu15-Jun-04 22:29
memberkarl_hsu15-Jun-04 22:29 
GeneralHiding the Scrollbars Option Pin
coding-nastypcs10-May-04 3:49
membercoding-nastypcs10-May-04 3:49 
GeneralImage Loading Animation Pin
coding-nastypcs27-Apr-04 4:40
membercoding-nastypcs27-Apr-04 4:40 
GeneralRe: Image Loading Animation Pin
João Paulo Figueira27-Apr-04 5:44
memberJoão Paulo Figueira27-Apr-04 5:44 

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.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150603.1 | Last Updated 3 Nov 2003
Article Copyright 2003 by João Paulo Figueira
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid