1
/*Intel Corporation has released a number of extremely useful libraries and tools as part
2
of their performance suite. These tools are designed to assist developers in taking
3
advantage of their advanced processors.
5
One excellent tool is the Intel Jpeg Library which provides a single small DLL which
6
will rapidly compress and decompress Jpeg images, a common graphics file format.
8
The following code snippet provides a static wrapper class for this library. The
9
only thing you need besides this code snippet is IJL.H, IJL.LIB, IJL.DLL which can
10
be found at the following URL.
13
http://www-cs.intel.com/support/performancetools/libraries/ijl/index.htm
15
When you see the quantity of code required just to compress or decompress a JPEG image
16
using IJL I think you will see the value of the following simplified wrapper layer.
21
//*** The JPEG.H wrapper layer header file.
26
//############################################################################
30
//## Wrapper class to compress or decompress a jpeg from a block of memory ##
31
//## using the Intel Jpeg Library. ##
32
//## OpenSourced 2/4/2000 by John W. Ratcliff ##
34
//## No warranty expressed or implied. Released as part of the triangle ##
35
//## throughput testbed project. ##
36
//############################################################################
38
//## Contact John W. Ratcliff at jratcliff@verant.com ##
39
//############################################################################
45
static bool ReadFileParams(int &width,
50
static bool ReadFile(int width,
54
unsigned char *pixbuff);
56
static void *ReadImage(int &width, // width of the image loaded.
57
int &height, // height of the image loaded.
58
int &bpp, // BYTES (not bits) PER PIXEL.
59
const void *buffer, // memory address containing jpeg compressed data.
60
int sizebytes); // size of jpeg compressed data.
63
static void * Compress(const void *buffer, // address of image in memory
64
int width, // width of image in pixels
65
int height, // height of image in pixels.
66
int bpp, // *BYTES* per pixel of image 1 or 3
67
int &len, // returns length of compressed data
68
int quality=75); // image quality as a percentage
70
static bool WriteFile(const void *buffer, // address of image in memory
71
int width, // width of image in pixels
72
int height, // height of image in pixels.
73
int bpp, // *BYTES* per pixel of image 1 or 3
75
int quality=75); // image quality as a percentage
77
static bool Compress(const void *source, // address of image in memory
78
unsigned char *dest, // buffer to hold the compressed image
79
int width, // width of image in pixels
80
int height, // height of image in pixels
81
int bpp, // *BYTES* per pixel of image 1 or 3
82
unsigned long &len, // returns length of compressed data
83
int quality=75); // image quality as a percentage
85
static bool ReadImage(int &width, // width of the image loaded.
86
int &height, // height of the image loaded.
87
int &bpp, // BYTES (not bits) PER PIXEL.
88
const void *buffer, // memory address containing jpeg compressed data.
89
long sizebytes, // size of jpeg compressed data.
90
unsigned char* dest); // buffer to hold the uncompressed image