~ubuntu-branches/ubuntu/hardy/libterralib/hardy

« back to all changes in this revision

Viewing changes to src/terralib/kernel/jpeg.h

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T Chen
  • Date: 2005-11-25 22:32:59 UTC
  • Revision ID: james.westby@ubuntu.com-20051125223259-3zubal8ux4ki4fjg
Tags: upstream-3.0.3b2
ImportĀ upstreamĀ versionĀ 3.0.3b2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.
 
4
 
 
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.
 
7
 
 
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.
 
11
 
 
12
 
 
13
http://www-cs.intel.com/support/performancetools/libraries/ijl/index.htm
 
14
 
 
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.
 
17
 
 
18
John W. Ratcliff
 
19
jratcliff@verant.com
 
20
*/
 
21
//*** The JPEG.H wrapper layer header file.
 
22
 
 
23
#ifndef JPEG_H
 
24
#define JPEG_H
 
25
 
 
26
//############################################################################
 
27
//##                                                                        ##
 
28
//##  JPEG.H                                                                ##
 
29
//##                                                                        ##
 
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                              ##
 
33
//##                                                                        ##
 
34
//##  No warranty expressed or implied.  Released as part of the triangle   ##
 
35
//##  throughput testbed project.                                           ##
 
36
//############################################################################
 
37
//##                                                                        ##
 
38
//##  Contact John W. Ratcliff at jratcliff@verant.com                      ##
 
39
//############################################################################
 
40
 
 
41
class Jpeg
 
42
{
 
43
public:
 
44
 
 
45
  static bool  ReadFileParams(int &width,
 
46
                                                int &height,
 
47
                                                int &nchannels,
 
48
                                                char *name);
 
49
 
 
50
  static bool  ReadFile(int width,
 
51
                                                int height,
 
52
                                                int nchannels,
 
53
                                                char *name,
 
54
                                                unsigned char *pixbuff);
 
55
 
 
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.
 
61
 
 
62
 
 
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
 
69
 
 
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
 
74
                                                 char *name,
 
75
                         int quality=75); // image quality as a percentage
 
76
 
 
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
 
84
 
 
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
 
91
 
 
92
};
 
93
 
 
94
#endif
 
95