Click here to Skip to main content
Licence CPOL
First Posted 12 Aug 2002
Views 143,315
Bookmarked 25 times

Loading images with an undocumented API in PPC 2002

By | 12 Aug 2002 | Article
This article describes an undocumented API that enables you to load images (bmp, gif etc.) from files under Pocket PC 2002

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

About the Author

Tanzim Husain

Web Developer

United States United States

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralImages not in the Resource directory Pinmemberspret8523:34 14 Sep '09  
Questionhow to load tiff file image from java or c Pinmembermikerahul1:40 13 Oct '07  
Questionloading JPEG from stream? Pinmemberhouari_id8:18 20 Mar '06  
GeneralThe unanimation bug Pinmembereagleanec21:15 20 Feb '06  
QuestionHow to show image from jpeg stream? Pinmemberrobert101417:55 17 Sep '05  
Generalfriends, you solved my great problem Pinmemberjiang shanshan19:04 25 Aug '05  
Generalworks on pocket pc 2003 as well PinsussKang Jodhi20:56 7 Mar '05  
GeneralWorks with JPG too PinsussAnonymous16:46 7 Feb '05  
Questionhow about in eVB ? PinsussAnonymous1:50 16 Jan '04  
QuestionUse SHLoadImageFile in dialog-based application? Pinmembercwei_lim14:37 30 Dec '03  
GeneralAbout SHLoadImageFile PinmemberALopatkin22:34 26 Oct '03  
GeneralRe: About SHLoadImageFile PinsussAnonymous18:16 19 Nov '03  
GeneralRe: About SHLoadImageFile PinmemberLiptenSoup11:09 14 Jan '04  
GeneralIt is in MSDN PinsussAnonymous0:06 26 Oct '03  
GeneralRe: It is in MSDN PinsussAnonymous3:22 13 Feb '04  
GeneralGive a hand pls~~^_^ Pinmemberwehaha2:19 10 Sep '03  
GeneralI couldnt compile.... PinmemberRamees21:14 10 May '03  
GeneralRe: I couldnt compile.... PinmemberTanzim Husain19:11 30 May '03  
GeneralRe: I couldnt compile.... PinsussAnonymous0:12 8 Jun '03  
GeneraleVB PinsussChetan Kapadia2:58 17 Jan '03  
QuestionHow to Images in WinCE4.1 - A Probable solution Pinmembertanzim22:41 25 Sep '02  
QuestionHow to Images in WinCE4.1 ? PinsussDrWatson23:12 1 Sep '02  
AnswerRe: How to Images in WinCE4.1 ? Pinmembertanzim22:19 2 Sep '02  
GeneralRe: How to Images in WinCE4.1 ? PinsussDrWatson20:32 3 Sep '02  
GeneralRe: How to Images in WinCE4.1 ? PinsussHouser23:28 7 Sep '02  

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.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120528.1 | Last Updated 13 Aug 2002
Article Copyright 2002 by Tanzim Husain
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid