Click here to Skip to main content
Click here to Skip to main content

Loading images with an undocumented API in PPC 2002

, 12 Aug 2002
Rate this:
Please Sign up or sign in to vote.
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)

Share

About the Author

Tanzim Husain
Web Developer
United States United States
No Biography provided

Comments and Discussions

 
GeneralImages not in the Resource directory Pinmemberspret8514-Sep-09 23:34 
Questionhow to load tiff file image from java or c Pinmembermikerahul13-Oct-07 1:40 
Questionloading JPEG from stream? Pinmemberhouari_id20-Mar-06 8:18 
GeneralThe unanimation bug Pinmembereagleanec20-Feb-06 21:15 
QuestionHow to show image from jpeg stream? Pinmemberrobert101417-Sep-05 17:55 
Generalfriends, you solved my great problem Pinmemberjiang shanshan25-Aug-05 19:04 
Generalworks on pocket pc 2003 as well PinsussKang Jodhi7-Mar-05 20:56 
GeneralWorks with JPG too PinsussAnonymous7-Feb-05 16:46 
Questionhow about in eVB ? PinsussAnonymous16-Jan-04 1:50 
QuestionUse SHLoadImageFile in dialog-based application? Pinmembercwei_lim30-Dec-03 14:37 
GeneralAbout SHLoadImageFile PinmemberALopatkin26-Oct-03 22:34 
GeneralRe: About SHLoadImageFile PinsussAnonymous19-Nov-03 18:16 
GeneralRe: About SHLoadImageFile PinmemberLiptenSoup14-Jan-04 11:09 
GeneralIt is in MSDN PinsussAnonymous26-Oct-03 0:06 
GeneralRe: It is in MSDN PinsussAnonymous13-Feb-04 3:22 
GeneralGive a hand pls~~^_^ Pinmemberwehaha10-Sep-03 2:19 
GeneralI couldnt compile.... PinmemberRamees10-May-03 21:14 
GeneralRe: I couldnt compile.... PinmemberTanzim Husain30-May-03 19:11 
GeneralRe: I couldnt compile.... PinsussAnonymous8-Jun-03 0:12 
GeneraleVB PinsussChetan Kapadia17-Jan-03 2:58 
QuestionHow to Images in WinCE4.1 - A Probable solution Pinmembertanzim25-Sep-02 22:41 
QuestionHow to Images in WinCE4.1 ? PinsussDrWatson1-Sep-02 23:12 
AnswerRe: How to Images in WinCE4.1 ? Pinmembertanzim2-Sep-02 22:19 
GeneralRe: How to Images in WinCE4.1 ? PinsussDrWatson3-Sep-02 20:32 
GeneralRe: How to Images in WinCE4.1 ? PinsussHouser7-Sep-02 23:28 

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 | Mobile
Web03 | 2.8.140827.1 | Last Updated 13 Aug 2002
Article Copyright 2002 by Tanzim Husain
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid