Decompressing JPEG images on Palm OS handhelds is easy if you are a user – just get RescoViewer. Developers who want to benefit from JPEG compression(great for backgrounds in games,…) on the other hand need to fight pnoJpegLib. I now have a program working – here’s what I did:
Step 1: make pnoJpegLib compile
After downloading the library from its homepage and including it into your PODS project(move both into the projects path and refresh the project by right-clicking onto the file tree list and clicking refresh), include the header file into all files that need to access the pnoJpegLib. I use the code below, the library resides in a subdirectory:
Then, open pnoJpeg.c and pnoJpeg.h and remove the inline statements to make the function definitions look like this:
Err pnoJpeg_OpenLibrary(UInt16 *refNumP)
After that, the project should compile. In case it still doesn’t, my files will be at the bottom of the second part of this article!
Step 2: prepare pnoJpegLib
Now, in the app opening code, include the following:
FrmCustomAlert(AltNotification,"JPEG library not found. Please install it from the distribution file!n","Background images disbled!","");
//Create JPEG ref
jpgenable is a Boolean value that lets you determine if the library is installed onto the Palm OS device where your app currently runs. jpgrefnum is a global UInt16, and jpgp is a global pnoJpeg2Ptr.
!!!There is NO NEED to allocate memory – the library handles this on its own. All you need to do is define the pointer!!!
Closing the library is easy, too – use the code below:
pnoJpeg2Free must be used once for each pointer you define. You can have multiple pointers in your app. Such a “pointer” essentially stores source and conversion information about a jpeg image and can be passed to the reader in order to generate bitmap data!
Congratulations – we now have pnoJpegLibrary ready to convert images. The second part of this article will look at adding jpeg files to your project and drawing them…tune in soon!