5,138,005 members and growing! (12,821 online)
Email Password   helpLost your password?
Platforms, Frameworks & Libraries » Mobile Development » Graphics and Multimedia     Intermediate

Loading Images with undocumented API in PPC 2002

By Tanzim Husain

This article describes an undocumented API that enables you to load images (bmp, gif etc.) from files under Pocket PC 2002
C++, eVC 4.0, eVC, Windows, WinCE, Visual Studio, PDA, WinMobile2002, Dev

Posted: 12 Aug 2002
Updated: 12 Aug 2002
Views: 108,005
Announcements



Search    
Advanced Search
Sitemap
20 votes for this Article.
Popularity: 5.39 Rating: 4.14 out of 5
1 vote, 7.1%
1
0 votes, 0.0%
2
1 vote, 7.1%
3
3 votes, 21.4%
4
9 votes, 64.3%
5

Introduction

Loading images under windows can always be a painful process, especially if the image formats are like JPEG, GIF or PNG. There's always the Imgdecmp library, that does a good job, but its also a bit of a bother with the documentation being so thin and all that. The other day I was trying to load a bitmap from my device using LoadImage, but somehow I kept getting the dreaded "The handle is invalid" error. So I did a search on the MFC code that ships with the PPC SDK in hope of finding a piece of code that will help me solve the puzzle. 

One thing led to another. I suddenly came across HBITMAP SHLoadImageFile(LPCTSTR pszFileName) in aygshell.h. Bingo! I had suddenly uncovered an undocumented API! No trace of it in MSDN, a search in Google produced nothing!! Since then, I've tried this API with gif's and bmp's also and I guess it will work fine for jpeg's and png's too. Here's a code sample...

// assuming code is in the OnDraw method of a view....


CBitmap bitmap;

// Attach the bitmap object to the HBITMAP returned by SHLoadImageFile

bitmap.Attach(SHLoadImageFile(_T("/My Documents/mcdonalds.gif")));

BITMAP bmpInfo;
bitmap.GetBitmap(&bmpInfo);

CDC bitmapDC;
bitmapDC.CreateCompatibleDC(pDC);
CBitmap* pOldBitmap = bitmapDC.SelectObject(&bitmap);

pDC->BitBlt(0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, &bitmapDC, 
            0, 0, SRCCOPY);

bitmapDC.SelectObject(pOldBitmap);
bitmap.DeleteObject();

That's all for now.

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

Tanzim Husain



Occupation: Web Developer
Location: United States United States

Other popular Mobile Development articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 25 of 34 (Total in Forum: 34) (Refresh)FirstPrevNext
Subject  Author Date 
Generalhow to load tiff file image from java or cmembermikerahul2:40 13 Oct '07  
Generalloading JPEG from stream?memberhouari_id9:18 20 Mar '06  
GeneralThe unanimation bugmembereagleanec22:15 20 Feb '06  
QuestionHow to show image from jpeg stream?memberrobert101418:55 17 Sep '05  
Generalfriends, you solved my great problemmemberjiang shanshan20:04 25 Aug '05  
Generalworks on pocket pc 2003 as wellsussKang Jodhi21:56 7 Mar '05  
GeneralWorks with JPG toosussAnonymous17:46 7 Feb '05  
Generalhow about in eVB ?sussAnonymous2:50 16 Jan '04  
GeneralUse SHLoadImageFile in dialog-based application?membercwei_lim15:37 30 Dec '03  
GeneralAbout SHLoadImageFilememberALopatkin23:34 26 Oct '03  
GeneralRe: About SHLoadImageFilesussAnonymous19:16 19 Nov '03  
GeneralRe: About SHLoadImageFilememberLiptenSoup12:09 14 Jan '04  
GeneralIt is in MSDNsussAnonymous1:06 26 Oct '03  
GeneralRe: It is in MSDNsussAnonymous4:22 13 Feb '04  
GeneralGive a hand pls~~^_^memberwehaha3:19 10 Sep '03  
GeneralI couldnt compile....memberRamees22:14 10 May '03  
GeneralRe: I couldnt compile....memberTanzim Husain20:11 30 May '03  
GeneralRe: I couldnt compile....sussAnonymous1:12 8 Jun '03  
GeneraleVBsussChetan Kapadia3:58 17 Jan '03  
GeneralHow to Images in WinCE4.1 - A Probable solutionmembertanzim23:41 25 Sep '02  
GeneralHow to Images in WinCE4.1 ?sussDrWatson0:12 2 Sep '02  
GeneralRe: How to Images in WinCE4.1 ?membertanzim23:19 2 Sep '02  
GeneralRe: How to Images in WinCE4.1 ?sussDrWatson21:32 3 Sep '02  
GeneralRe: How to Images in WinCE4.1 ?sussHouser0:28 8 Sep '02  
GeneralRe: How to Images in WinCE4.1 ?sussAnonymous12:35 21 Jan '03  

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

PermaLink | Privacy | Terms of Use
Last Updated: 12 Aug 2002
Editor: Chris Maunder
Copyright 2002 by Tanzim Husain
Everything else Copyright © CodeProject, 1999-2008
Web10 | Advertise on the Code Project