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:

#include "pnojpeglib/pnoJpeg.h"

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!

Related posts:

  1. pnoJpegLib and PODS – the tutorial – Part 2
  2. Creating Multi-Segment applications with PODS
  3. Renaming a file busts PODS
  4. Compiling FontBucket with PODS 1.2
  5. Globals in DAs

One Response to “pnoJpegLib and PODS – the tutorial – Part 1”

  1. Hi Tam!

    Nice Tutorial.
    But i’ve got one question or remark. I don’t think that it is a god idea only to remove the “inline”-statement in the header-file. You also should move the implementation to a c-file and only let the declaration in the header. IMHO Otherwise you will get an compiler-error if you include the pnoJpeg.h more than one times. The reason why the implementation of the Open and the Close Function is in the Header-File is the inline-Statement.

    Best Regards

    Stefan Stolz

    P.S. And about what “pnoJpeg.c” are you talking? There isn’t a pnoJpeg.c in my Lib… :-)

Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe without commenting

© 2013 TamsPalm - the Palm OS / web OS Blog Suffusion theme by Sayontan Sinha