Click here to Skip to main content
Email Password   helpLost your password?

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:

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.

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
Generalwhat to do with hBmp after use?
Kalian
3:31 14 Jun '07  
Hi!

Thanks alot for your useful code.

If have one question. In my program, I load many pictures do show in a listview (thumbnails). The handle to the bitmap (HBITMAP) gets lost after drawing the picture. If the picture needs to be redrawn, it will be read again from the file.

So my question, before the handle is lost, do I need to free up the memory where the bitmap is stored?

Thanks alot for your help!

Philipp
GeneralRe: what to do with hBmp after use?
Joao Paulo Figueira
8:43 14 Jun '07  
You must release the hBmp after use. How are you loading it?

Regards,
João Paulo Figueira
DAD MVP

GeneralRe: what to do with hBmp after use?
Kalian
23:48 19 Jun '07  
I load the picture as shown in your example with help of DecompressImageIndirect:

...
dii.phBM = & hBmp;
...
hr = DecompressImageIndirect(& dii);
...

Then I use
dcMem.SelectObject(hBmp);
to draw the picture.

I don't want to save the picture in the memory after it has been drawn. So before loading the next picture (and of course before hBmp gets lost when leaving the function), I need to call
DeleteObject(hBmp);
Do I understand that right?

Thanks again!
Philipp
GeneralHow to make folders permanent in PPC2002/ppc2003??
amit4all
6:51 8 Apr '07  
Hello...I am currently developing an application in evc 3.0 for a PDA(iPAQ) and I want this app and some folders related to it to stay in the device even if reset is done(which erases all the files loaded externally to it)!!

How can it be done??
Plzz help!!

Also another thing, if I want to protect some folders from user access, what should I do??

plzz somebody reply if u know this!!

aMIT sARKAR

Generalevc++ linking problem...
killerLee
20:27 18 Jun '06  
Great job, I use evc++ 4.0 sp4 and pocket pc 2003.
evc++ linking problem....help..

warning C4273: 'protected: static class CDC CVOImage::g_dc' : inconsistent dll linkage. dllexport assumed.
error C2491: 'CVOImage::g_dc' : definition of dllimport static data member not allowed
warning C4273: 'protected: static int CVOImage::g_iScale' : inconsistent dll linkage. dllexport assumed.
error C2491: 'CVOImage::g_iScale' : definition of dllimport static data member not allowed
warning C4273: 'protected: static int CVOImage::g_iMaxWidth' : inconsistent dll linkage. dllexport assumed.
error C2491: 'CVOImage::g_iMaxWidth' : definition of dllimport static data member not allowed
warning C4273: 'protected: static int CVOImage::g_iMaxHeight' : inconsistent dll linkage. dllexport assumed.
error C2491: 'CVOImage::g_iMaxHeight' : definition of dllimport static data member not allowed
error C2065: 'LEFT_ALIGN' : undeclared identifier
....
Generating Code...
Error executing cl.exe.


Sorry, I'm poor in English..
GeneralImage disappear
houari_id
7:48 24 Mar '06  
I am trying to implement the imgdecmp using Dialog-based mfc. Everything is fine, except that while the image is being displayed on the screen, then I click on start menu, or change the volume, the image is disappear.
How can I keep the image?

Thank you...
GeneralRe: Image disappear
João Paulo Figueira
0:27 25 Mar '06  
What is your device OS?

Regards,
João Paulo Figueira
Embedded MVP
GeneralRe: Image disappear
houari_id
3:45 25 Mar '06  
Hi, thank you for reply.

I am using Windows Mobile 2003 SE. (windows CE 4.21)
Actually, in MFC for PC, I can handle this problem using OnPaint method, but it doesn't seem to work here.

Thank you
GeneralHow to show image from winsock buffer?
robert1014
2:02 16 Sep '05  
If jpeg source from buffer not file, how can I convert image to bitmap from buffer?
thank you
Generalevc++ linking problem... Helpp!!!
viveksundaram
4:25 10 Apr '05  
Sorry... this msg has nothing to do with the picture viewer... I just need some help on a similar issue of linking... I use evc++ 4.0 sp4. I get the following error while linking... I use win32(WCE x86) Debug and StandardSDK Emulator...

Linking...
corelibc.lib(pegwmain.obj) : error LNK2019: unresolved external symbol _WinMain referenced in function _WinMainCRTStartup
X86Dbg/l.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

l.exe - 2 error(s), 0 warning(s)
I tried \force multiple and it didnt work....

plz helllppp!!!

Thanx,
Vivek
GeneralRe: evc++ linking problem... Helpp!!!
Daniel Jin
5:15 24 Apr '05  
It seems your code has some MFC and Non-MFC Conflict.

If you took some codes from the others, check their complier and linker settings.

Regards.

Daniel J. Kim.
InSoftware House.
GeneralRe: evc++ linking problem... Helpp!!!
John Francis Shade
1:32 1 Feb '06  
i ve got tha same too









DAMN!!!!!!!!!!!!!!!!!!!!!







GeneralRe: evc++ linking problem... Helpp!!!
John Francis Shade
22:34 1 Feb '06  
i ve got it (the solution)
you should somewhere in eVC menu settings
change WinMainCRTStartup to wWinMainCRTStartup
or wWinMainCRTStartup to WinMainCRTStartup
(i forgot which)

JSF
GeneralRe: evc++ linking problem... Helpp!!!
jitendra lokwani
21:42 21 Jul '06  
plz tell me where i have to set WinMainCRTStartup to wWinMainCRTStartup or wWinMainCRTStartup to WinMainCRTStartup...

Thanks & regards,
Jitendra Lokwani



GeneralRe: evc++ linking problem... Helpp!!!
Androides
0:41 11 Oct '06  
(in the menu) Project->settings->link tab->under Project options.

besides that, I've now changed "WinMainCRTStartup" to "wWinMainCRTStartup".

now I get:

error LNK2019:
unresolved external symbol _wWinMain referenced in function _wWinMainCRTStartup

now what?Confused
GeneralPicView for evc 4.0 ?
riki_risnandar
3:06 26 Dec '04  
Great job, Im really really interested to try this, its simple and powerfull. i wanna implement this to my skinned application.

but i cannot open it.do you have this project in evc 4.0 version ? or maybe theres some converter to export from evc 3.0 project to 4.0 ?

thanks before
GeneralRe: PicView for evc 4.0 ?
João Paulo Figueira
23:45 26 Dec '04  
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 ?
riki_risnandar
6:31 27 Dec '04  
i see. I try your way and its working Big Grin even there's a lot of copy pasting through the code.
i can send u the project picview in evc 4.0 if you're interested so other members can download it.

thanks

Riki Risnandar
GeneralRe: PicView for evc 4.0 ?
Joseph Ellsworth
21:56 24 May '05  
I would be interested in the EVC4 project


joe@xdobs.com
GeneralRe: PicView for evc 4.0 ?
riki_risnandar
8:44 27 May '05  
i already sent the project to your email.

Mr Joao. there's a lot of people asking me requesting these files, what if i send you the file ?

Riki Risnandar
GeneralRe: PicView for evc 4.0 ?
avilap
21:43 22 Jun '05  
Hi,

Thanks for sending the code.

I ran PicView_EVC_4[1].0 project on EVC 4.0 .And it ran perfectly on Pocket PC 2003.

Then I tried to run it on STANDARDSDK_420 but I got lots of errors.

I just wanted to know whether we can run this on simple WINCE 5.0

akjh
GeneralRe: PicView for evc 4.0 ?
kk0223
20:06 16 Jan '08  
I would be interested in the EVC4 project, too.
Can you send it for me.
Thanks!
chenzm0919@gmail.com

KK CHEN

GeneralRe: PicView for evc 4.0 ?
wj840815@sohu.com
22:42 27 Jan '08  
I would be interested in the EVC4 project, too.
Can you send it for me.
Thanks!
wj840815@sohu.com
GeneralRe: PicView for evc 4.0 ?
cyg80
15:51 17 Jul '06  
Hi,

Is it possible to sent me a version of the evc 4.0 of the code

Thanks
GeneralAccess the pixel
Peter0001
1:03 25 Dec '04  
Thank you very much! it's a really good

if i want to access the image pixels, how can i do that

did dii contain the starting position of pixels

Many thanks!


Last Updated 3 Nov 2003 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2010