Click here to Skip to main content
6,305,776 members and growing! (16,379 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, Windows, Win Mobile (PocketPC 2002), Visual Studio, Dev
Posted:12 Aug 2002
Views:122,289
Bookmarked:22 times
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
20 votes for this article.
Popularity: 5.39 Rating: 4.14 out of 5
1 vote, 7.1%
1

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


Member

Occupation: Web Developer
Location: United States United States

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 34 (Total in Forum: 34) (Refresh)FirstPrevNext
Generalhow to load tiff file image from java or c Pinmembermikerahul2:40 13 Oct '07  
Generalloading JPEG from stream? Pinmemberhouari_id9:18 20 Mar '06  
GeneralThe unanimation bug Pinmembereagleanec22:15 20 Feb '06  
QuestionHow to show image from jpeg stream? Pinmemberrobert101418:55 17 Sep '05  
Generalfriends, you solved my great problem Pinmemberjiang shanshan20:04 25 Aug '05  
Generalworks on pocket pc 2003 as well PinsussKang Jodhi21:56 7 Mar '05  
GeneralWorks with JPG too PinsussAnonymous17:46 7 Feb '05  
Generalhow about in eVB ? PinsussAnonymous2:50 16 Jan '04  
GeneralUse SHLoadImageFile in dialog-based application? Pinmembercwei_lim15:37 30 Dec '03  
GeneralAbout SHLoadImageFile PinmemberALopatkin23:34 26 Oct '03  
GeneralRe: About SHLoadImageFile PinsussAnonymous19:16 19 Nov '03  
GeneralRe: About SHLoadImageFile PinmemberLiptenSoup12:09 14 Jan '04  
GeneralIt is in MSDN PinsussAnonymous1:06 26 Oct '03  
GeneralRe: It is in MSDN PinsussAnonymous4:22 13 Feb '04  
GeneralGive a hand pls~~^_^ Pinmemberwehaha3:19 10 Sep '03  
GeneralI couldnt compile.... PinmemberRamees22:14 10 May '03  
GeneralRe: I couldnt compile.... PinmemberTanzim Husain20:11 30 May '03  
GeneralRe: I couldnt compile.... PinsussAnonymous1:12 8 Jun '03  
GeneraleVB PinsussChetan Kapadia3:58 17 Jan '03  
GeneralHow to Images in WinCE4.1 - A Probable solution Pinmembertanzim23:41 25 Sep '02  
GeneralHow to Images in WinCE4.1 ? PinsussDrWatson0:12 2 Sep '02  
GeneralRe: How to Images in WinCE4.1 ? Pinmembertanzim23:19 2 Sep '02  
GeneralRe: How to Images in WinCE4.1 ? PinsussDrWatson21:32 3 Sep '02  
GeneralRe: How to Images in WinCE4.1 ? PinsussHouser0:28 8 Sep '02  
GeneralRe: How to Images in WinCE4.1 ? PinsussAnonymous12: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-2009
Web16 | Advertise on the Code Project