![]() |
|
Using IJG JPEG library
By Andrey Yatsyk, September 18, 2001.
IntroductionIndependent JPEG Group distributes freeware library for JPEG image file processing. You can find the library download locations at their web site www.ijg.org. This article describes how to port the version marked "6b" to Pocket PC. What You Need
BackgroundThe jpeg library is configured by two header files: jconfig.h and jmorecfg.h. It is assumed that the second one is not edited by a programmer, but I have faced issues that could not be solved without jmorecfg.h changing. In the following sentences we will discuss changes of these two files needed for using jpeg library in your Pocket PC applications. Jpeg library archive contains jconfig.h for a number of platforms and development environments. I think that the most comfortable way for porting is to take this file for close platform and to change it. I used Visual Studio version. The only change needed for this file is adding #define NO_GETENV because getenv() method is not supported in Pocket PC. Porting JpegLib for Pocket PCThe jmorecfg.h file has definitions that conflict with Embedded Visual Studio ones. You must make the following changes: 1. Code: should be changed to: 2. and code should be wrapped with the following ifdef There you can download Embedded Visual Studio project that includes all JPEG library files needed for jpeg compression and decompression. This project will be used in our test program or your applications if you wish to use JPEG library for image data loading. Using JpegLibNow I will show how to use IJG JPEG library for loading and displaying an image in a Pocket PC application. The case this application uses is very simple and you need to add extra error handling code in order to use this library in a serious application. Here I provide step-by-step instructions for creating simple dialog based MFC application that can display a JPEG image:
You can download workplace along with this application. If you want to develop useful Pocket PC programs using this JPEG library it is recommended that you consult in library documentation about adding user error handling code and library customization. In order to save the application simplicity this code does not handle some special cases; for example this application assumes three component jpeg file as they usually are and it crashes when you provide black and white images. Such cases need special coding because STScreenBuffer expects three color components. ConclusionAfter porting JpegLib could be used as a very powerful tool for handling JPEG images in your application. Related resources:
DiscussDiscuss this article. Here you can write your comments and read comments of other developers. |
|||||||||||||||||||||